Music Is My Everest

{"totalPages":"1","currentPage":"1","nextPage":"","search":"","tag":"","indexPage":"",
"askLabel":"Ask me anything",
"submitLabel":"Submit",
"searchLabel":"Search",

"posts":{
"11187640763":{"id":"11187640763","date":"2011-10-08","noteCount": "7 notes","url":"http://musicismyeverest.tumblr.com/post/11187640763/log-switch-0-1-0-released","rebloggingUrl":"http://www.tumblr.com/reblog/11187640763/ebjJERI7","reblog":"","hasTags":"true",
"tags":[{"tagUrl":"http://musicismyeverest.tumblr.com/tagged/ruby/chrono","tag":"ruby"},{"tagUrl":"http://musicismyeverest.tumblr.com/tagged/rubygems/chrono","tag":"rubygems"},{"tagUrl":"http://musicismyeverest.tumblr.com/tagged/log_switch/chrono","tag":"log_switch"},{"tagUrl":"http://musicismyeverest.tumblr.com/tagged/release/chrono","tag":"release"},{}],"tagCaption":"Tags","permalinkPage":"true","notesUrl":"http://musicismyeverest.tumblr.com/notes/11187640763/xkNwYLtXo",

"type":"text","title":"log_switch%200.1.0%20released%21","body":"%3Ch2%3E%0A%3Ch2%3EDESCRIPTION%3C%2Fh2%3E%0A%3C%2Fh2%3E%3Cp%3EWhile%20developing%20other%20gems%20that%20required%20a%20single%20class%2Fsingleton%20style%20logger%2C%20I%20got%20tired%20of%20repeating%20the%20code%20to%20create%20that%20logger%20and%20mix%20it%20in%20to%20my%20base%20class.%20I%20just%20wanted%20to%20be%20able%20to%20require%20something%2C%20then%20be%20able%20to%20do%3A%3C%2Fp%3E%0A%3Cpre%3EMyLib.log%20%22some%20message%22%3C%2Fpre%3E%0A%3Cp%3EI%20also%20wanted%20to%20be%20able%20to%20programmatically%20turn%20on%2Foff%20logging%20by%20doing%20something%20like%3A%3C%2Fp%3E%0A%3Cpre%3EMyLib.log%20%3D%20false%3C%2Fpre%3E%0A%3Cp%3EThis%20gem%20allows%20just%20that.%20Well%2C%20almost%E2%80%A6%3C%2Fp%3E%0A%3Ch2%3EFEATURES%2FPROBLEMS%3C%2Fh2%3E%0A%3Cp%3EFeatures%3A%3C%2Fp%3E%0A%3Cul%3E%3Cli%3E%0A%3Cp%3Erequire%C2%A0and%C2%A0extend%C2%A0to%20mix%20in%20to%20your%20class%2Fmodule%20to%20get%20a%20single%20point%20of%20logging%3C%2Fp%3E%0A%3C%2Fli%3E%0A%3Cli%3E%0A%3Cp%3ESwitch%20on%2Foff%20logging%3C%2Fp%3E%0A%3C%2Fli%3E%0A%3Cli%3E%0A%3Cp%3EUse%20whatever%20Logger%20you%20want%3C%2Fp%3E%0A%3C%2Fli%3E%0A%3C%2Ful%3E%3Ch2%3ESYNOPSIS%3C%2Fh2%3E%0A%3Cp%3EGet%20your%20app%20logging%20with%20a%20single%20point%20of%20logging%3A%3C%2Fp%3E%0A%3Cpre%3Erequire%20%27log_switch%27%0A%0Aclass%20MyThing%0A%20%20extend%20LogSwitch%0Aend%0A%0AMyThing.log%20%22I%20like%20you%2C%20Ruby.%22%20%20%23%20%3D%26gt%3B%20D%2C%20%5B2011-10-07T14%3A40%3A26.697084%20%2330080%5D%20DEBUG%20--%20%3A%20I%20like%20you%2C%20Ruby.%3C%2Fpre%3E%0A%3Cp%3E%E2%80%A6and%20then%20you%20can%20simply%20switch%20off%20logging%20by%20doing%3A%3C%2Fp%3E%0A%3Cpre%3EMyThing.log%20%3D%20false%0AMyThing.log%20%22You%27re%20my%20favorite.%22%20%23%20%3D%26gt%3B%20No%20logging%20occurs%21%3C%2Fpre%3E%0A%3Cp%3EBy%20default%2C%20LogSwitch%20sets%20the%20log%20level%20to%20%3Adebug.%20You%20can%20change%20the%20default%20log%20level%20as%20you%20go%3A%3C%2Fp%3E%0A%3Cpre%3EMyThing.log_level%20%3D%20%3Awarn%0AMyThing.log%20%22Crap%21%22%20%20%20%20%20%20%20%20%20%20%20%23%20%3D%26gt%3B%20W%2C%20%5B2011-10-07T15%3A30%3A54.012502%20%2332892%5D%20%20WARN%20--%20%3A%20Crap%21%3C%2Fpre%3E%0A%3Cp%3EYou%20can%20pass%20in%20the%20log%20level%20for%20your%20Logger%20type%20too%3A%3C%2Fp%3E%0A%3Cpre%3EMyThing.log%20%22Stuff%21%22%2C%20%3Ainfo%20%20%20%20%20%20%23%20%3D%26gt%3B%20I%2C%20%5B2011-10-07T15%3A28%3A49.480741%20%2332892%5D%20%20INFO%20--%20%3A%20Stuff%21%0AMyThing.log%20%22Meow%22%2C%20%3Afatal%20%20%20%20%20%20%20%23%20%3D%26gt%3B%20F%2C%20%5B2011-10-07T15%3A32%3A21.207867%20%2332892%5D%20FATAL%20--%20%3A%20Meow%3C%2Fpre%3E%0A%3Cp%3EIf%20you%20have%20another%20Logger%20object%20you%20want%20to%20write%20to%2C%20no%20problem%3A%3C%2Fp%3E%0A%3Cpre%3Esome_other_logger%20%3D%20Logger.new%20%27log.txt%27%0AMyThing.logger%20%3D%20some_other_logger%0AMyThing.log%20%22hi%21%22%0AFile.open%28%27log.txt%27%2C%20%27r%27%29.read%20%20%20%20%23%20%3D%26gt%3B%20Logfile%20created%20on%202011-10-07%2015%3A50%3A19%20-0700%20by%20logger.rb%2F25413%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20%20%20%20D%2C%20%5B2011-10-07T15%3A51%3A16.385798%20%2334026%5D%20DEBUG%20--%20%3A%20hi%21%3C%2Fpre%3E%0A%3Ch2%3EREQUIREMENTS%3C%2Fh2%3E%0A%3Cul%3E%3Cli%3E%0A%3Cp%3ERuby%201.9.2%3C%2Fp%3E%0A%3C%2Fli%3E%0A%3Cli%3E%0A%3Cp%3ERubyGems%3A%3C%2Fp%3E%0A%3Cul%3E%3Cli%3E%0A%3Cp%3ENone%21%3C%2Fp%3E%0A%3C%2Fli%3E%0A%3C%2Ful%3E%3C%2Fli%3E%0A%3C%2Ful%3E%3Ch2%3EINSTALL%3C%2Fh2%3E%0A%3Cpre%3E%24%20gem%20install%20log_switch%3C%2Fpre%3E"

 },
"":{} }}