Class: Lotus::Logger
- Inherits:
-
Logger
- Object
- Logger
- Lotus::Logger
- Defined in:
- lib/lotus/logger.rb
Overview
Lotus logger
Implement with the same interface of Ruby std lib ‘Logger`. It uses `STDOUT` as output device.
When a Lotus application is initialized, it creates a logger for that specific application. For instance for a ‘Bookshelf::Application` a `Bookshelf::Logger` will be available.
This is useful for auto-tagging the output. Eg (‘[Booshelf]`).
When used stand alone (eg. ‘Lotus::Logger.info`), it tags lines with `[Shared]`.
The available severity levels are the same of ‘Logger`:
* debug
* error
* fatal
* info
* unknown
* warn
Those levels are available both as class and instance methods.
Defined Under Namespace
Classes: Formatter
Constant Summary collapse
- DEFAULT_APPLICATION_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default application name. This is used as a fallback for tagging purposes.
'Lotus'.freeze
Instance Attribute Summary collapse
-
#application_name ⇒ String
Returns the current application name, this is used for tagging purposes.
Instance Method Summary collapse
-
#initialize(application_name = nil) ⇒ Logger
constructor
Initialize a logger.
Constructor Details
#initialize(application_name = nil) ⇒ Logger
Initialize a logger
109 110 111 112 113 114 |
# File 'lib/lotus/logger.rb', line 109 def initialize(application_name = nil) super(STDOUT) @application_name = application_name @formatter = Lotus::Logger::Formatter.new.tap { |f| f.application_name = self.application_name } end |
Instance Attribute Details
#application_name ⇒ String
Returns the current application name, this is used for tagging purposes
121 122 123 |
# File 'lib/lotus/logger.rb', line 121 def application_name @application_name || _application_name_from_namespace || _default_application_name end |