-
-
Save SingularityMatrix/64076045b42d40ee9d14 to your computer and use it in GitHub Desktop.
Revisions
-
kinopyo revised this gist
Oct 11, 2011 . 3 changed files with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # lib/custom_logger.rb class CustomLogger < Logger def format_message(severity, timestamp, progname, msg) "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,2 @@ # in development.rb require "custom_logger" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # in controller files CUSTOM_LOGGER.info("info from custom logger") CUSTOM_LOGGER.debug("debug from custom logger") CUSTOM_LOGGER.error("error from custom logger") -
kinopyo created this gist
Oct 11, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ class CustomLogger < Logger def format_message(severity, timestamp, progname, msg) "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" end end logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file logfile.sync = true # automatically flushes data to file CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ require "custom_logger" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # usage CUSTOM_LOGGER.info("info from custom logger") CUSTOM_LOGGER.debug("debug from custom logger") CUSTOM_LOGGER.error("error from custom logger")