Skip to content

Instantly share code, notes, and snippets.

@harigopal
Created April 15, 2017 15:55
Show Gist options
  • Save harigopal/2d9d7ffeedbb360f70381559dbcb7766 to your computer and use it in GitHub Desktop.
Save harigopal/2d9d7ffeedbb360f70381559dbcb7766 to your computer and use it in GitHub Desktop.
2017-04-15-service-loggable-concern
module Loggable
extend ActiveSupport::Concern
def log(message)
return if Rails.env.test?
Rails.logger.info "[#{current_timestamp}] [#{current_service_name}] #{message}\n"
end
private
def current_service_name
self.class.to_s
end
def current_timestamp
Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment