Class: UU::OS::Logger
- Inherits:
-
Object
- Object
- UU::OS::Logger
- Defined in:
- uu_os_framework-0.29.16/lib/uu/os/logger.rb,
uu_os_framework-0.29.16/lib/uu/os/logger/log_level.rb,
uu_os_framework-0.29.16/lib/uu/os/logger/mdc_provider.rb,
uu_os_framework-0.29.16/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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 22 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.
13 14 15 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 13 def name @name end |
Instance Method Details
- (Object) debug(msg, exception = nil, *params)
Logs debug message.
92 93 94 95 96 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 92 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.
99 100 101 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 99 def debug_loggable? return self.plugin.debug_loggable? end |
- (Object) error(msg, exception = nil, *params)
Logs error message.
44 45 46 47 48 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 44 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.
51 52 53 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 51 def error_loggable? return self.plugin.error_loggable? end |
- (Object) info(msg, exception = nil, *params)
Logs info message.
76 77 78 79 80 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 76 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.
83 84 85 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 83 def info_loggable? return self.plugin.info_loggable? end |
- (Object) level
Returns enabled logger level.
123 124 125 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 123 def level return self.plugin.level end |
- (Object) log(level, msg, exception = nil, *params)
Logs message.
109 110 111 112 113 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 109 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.
118 119 120 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 118 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.
132 133 134 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 132 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.
140 141 142 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 140 def mdc_remove(key) self.plugin.mdc_remove key end |
- (Object) warning(msg, exception = nil, *params)
Logs warning message.
60 61 62 63 64 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 60 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.
67 68 69 |
# File 'uu_os_framework-0.29.16/lib/uu/os/logger.rb', line 67 def warning_loggable? return self.plugin.warning_loggable? end |