code_junkie

Ruby - Ensure Syslog Gets Closed

Nov 11th, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class Foo
  2. def initialize
  3. @@log = Syslog.open("foo")
  4. end
  5. end
  6.  
  7. class Foo
  8. def do_something
  9. Syslog.open do
  10. # work with the syslog here
  11. end
  12. end
  13. end
  14.  
  15. class Foo
  16. def initialize
  17. @@log = Syslog.open("foo")
  18. end
  19.  
  20. def Foo.finalize(id)
  21. @@log.close if @@log
  22. end
  23. end
Add Comment
Please, Sign In to add comment