Created
July 11, 2018 17:13
-
-
Save hugodias/b8d1f3b81e28f6b7bf384dc535867f1b to your computer and use it in GitHub Desktop.
Rails 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 characters
# lib/custom_logger.rb | |
class CustomLogger | |
class << self | |
attr_accessor :logger | |
delegate :info, :warn, :debug, :error, :to => :logger | |
end | |
end |
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 characters
# config/initialize/custom_logger.rb | |
CustomLogger.logger = Logger.new(Rails.root.join("log", "custom.log")) |
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 characters
class SomeController < ApplicationController | |
def index | |
CustomLogger.info "Foo" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment