# Global.escape?

**URL:** <https://www.ruby-forum.com/t/global-escape/135050>\
**Category:** Ruby\
**Created:** [April 17, 2008, 1:27pm UTC](https://www.ruby-forum.com/t/global-escape/135050 "2008-04-17T13:27:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 17, 2008, 1:27pm UTC](https://www.ruby-forum.com/t/global-escape/135050/1 "2008-04-17T13:27:24Z")

</div>

Hi,

I have a logger class wrapped up a module as not to conflict with the  
Ruby logger class

module Utilities class Logger require "rexml/document" include REXML

def initialize  
@doc = Document.new  
xmldecl = XMLDecl.default  
@doc.add(xmldecl)  
@root = @doc.add\_element ‘testresults’  
end

def test\_case(test\_name, test\_desc)  
@test = @root.add\_element ‘test’  
@test.attributes[“id”] = test\_name  
des= @test.add\_element ‘description’  
des.text = test\_desc  
end

#cannot have a test result without a test case  
def test\_results(msg)  
if yield  
test\_status = @test.add\_element ‘teststatus’  
test\_status.text = ‘PASS’  
else  
fail = @test.add\_element ‘teststatus’  
fail.text = ‘FAIL’  
fail\_msg = @test.add\_element ‘failmessage’  
fail\_msg.text = msg  
end  
end

def write\_xml\_to\_file(file\_name=“C:/test\_results.xml”)  
@doc.write($stdout, 1)  
@doc.write(File.open(file\_name,“w”))  
end  
end  
end

I use this logger in various classes and modules, and I feel ashamed  
by using a global variable

$log = Utilities::Logger.new

I have tried using an attr\_reader on @root without success.

Is there anyway I can use this class in my project without using a  
global?

Regards

Aidy
