Skip to content

Instantly share code, notes, and snippets.

@hugodias
Created July 11, 2018 17:13
Show Gist options
  • Save hugodias/b8d1f3b81e28f6b7bf384dc535867f1b to your computer and use it in GitHub Desktop.
Save hugodias/b8d1f3b81e28f6b7bf384dc535867f1b to your computer and use it in GitHub Desktop.
Rails custom logger
# lib/custom_logger.rb
class CustomLogger
class << self
attr_accessor :logger
delegate :info, :warn, :debug, :error, :to => :logger
end
end
# config/initialize/custom_logger.rb
CustomLogger.logger = Logger.new(Rails.root.join("log", "custom.log"))
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