Class: UU::OS::Logger
- Inherits:
-
Object
- Object
- UU::OS::Logger
- Defined in:
- uu_os_framework-0.10.6/lib/uu/os/logger.rb,
uu_os_framework-0.10.6/lib/uu/os/logger/log_level.rb,
uu_os_framework-0.10.6/lib/uu/os/logger/mdc_provider.rb,
uu_os_framework-0.10.6/lib/uu/os/logger/log4r_plugin.rb
Overview
Logger component.
Defined Under Namespace
Classes: LogLevel
Instance Attribute Summary (collapse)
-
- (String) name
readonly
Logger name.
Instance Method Summary (collapse)
-
- (Object) debug(msg, exception = nil, *params)
Logs debug message.
-
- (Boolean) debug_loggable?
Checks if debug messages are enabled.
-
- (Object) error(msg, exception = nil, *params)
Logs error message.
-
- (Boolean) error_loggable?
Checks if error messages can be logged.
-
- (Object) info(msg, exception = nil, *params)
Logs info message.
-
- (Boolean) info_loggable?
Checks if info messages are enabled.
-
- (Logger) initialize(name, options = {})
constructor
Creates a new instance of Logger.
-
- (Object) level
Returns enabled logger level.
-
- (Object) log(level, msg, exception = nil, *params)
Logs message.
-
- (Boolean) loggable?(level)
Checks if given log level is enabled.
-
- (Object) mdc_put(key, value)
Put a context value as identified by key into mapped diagnostic context.
-
- (Object) mdc_remove(key)
Remove the context identified by the key parameter from mapped diagnostic context.
-
- (Object) warning(msg, exception = nil, *params)
Logs warning message.
-
- (Boolean) warning_loggable?
Checks if warning messages are enabled.
Constructor Details
- (Logger) initialize(name, options = {})
Creates a new instance of Logger.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 21 def initialize(name, = {}) raise ArgumentError, 'Logger name is required' unless name if (name.kind_of?String) && !name.empty? logger_name = name elsif (name.kind_of?Class) logger_name = name.name elsif (name.kind_of?Module) logger_name = name.name else logger_name = name.class.name end @name = logger_name @plugin = UU::OS::Logger::Log4rPlugin.new(self.name, ) end |
Instance Attribute Details
- (String) name
Logger name.
12 13 14 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 12 def name @name end |
Instance Method Details
- (Object) debug(msg, exception = nil, *params)
Logs debug message.
91 92 93 94 95 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 91 def debug(msg, exception=nil, *params) if debug_loggable? self.plugin.debug(msg, exception, *params) end end |
- (Boolean) debug_loggable?
Checks if debug messages are enabled.
98 99 100 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 98 def debug_loggable? return self.plugin.debug_loggable? end |
- (Object) error(msg, exception = nil, *params)
Logs error message.
43 44 45 46 47 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 43 def error(msg, exception=nil, *params) if error_loggable? self.plugin.error(msg, exception, *params) end end |
- (Boolean) error_loggable?
Checks if error messages can be logged.
50 51 52 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 50 def error_loggable? return self.plugin.error_loggable? end |
- (Object) info(msg, exception = nil, *params)
Logs info message.
75 76 77 78 79 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 75 def info(msg, exception=nil, *params) if info_loggable? self.plugin.info(msg, exception, *params) end end |
- (Boolean) info_loggable?
Checks if info messages are enabled.
82 83 84 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 82 def info_loggable? return self.plugin.info_loggable? end |
- (Object) level
Returns enabled logger level.
122 123 124 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 122 def level return self.plugin.level end |
- (Object) log(level, msg, exception = nil, *params)
Logs message.
108 109 110 111 112 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 108 def log(level, msg, exception=nil, *params) if loggable?(level) self.plugin.log(msg, exception, *params) end end |
- (Boolean) loggable?(level)
Checks if given log level is enabled.
117 118 119 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 117 def loggable?(level) return self.plugin.loggable?(level) end |
- (Object) mdc_put(key, value)
Put a context value as identified by key into mapped diagnostic context. Key and value can be nil.
131 132 133 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 131 def mdc_put(key, value) self.plugin.mdc_put(key, value) end |
- (Object) mdc_remove(key)
Remove the context identified by the key parameter from mapped diagnostic context. Key can be nil.
139 140 141 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 139 def mdc_remove(key) self.plugin.mdc_remove key end |
- (Object) warning(msg, exception = nil, *params)
Logs warning message.
59 60 61 62 63 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 59 def warning(msg, exception=nil, *params) if warning_loggable? self.plugin.warning(msg, exception, *params) end end |
- (Boolean) warning_loggable?
Checks if warning messages are enabled.
66 67 68 |
# File 'uu_os_framework-0.10.6/lib/uu/os/logger.rb', line 66 def warning_loggable? return self.plugin.warning_loggable? end |