Created
April 15, 2017 15:55
-
-
Save harigopal/2d9d7ffeedbb360f70381559dbcb7766 to your computer and use it in GitHub Desktop.
2017-04-15-service-loggable-concern
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
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