Module: Rogu
- Extended by:
- Rogu
- Included in:
- Rogu
- Defined in:
- lib/rogu.rb,
lib/rogu/version.rb,
lib/rogu/concern/logging.rb
Defined Under Namespace
Modules: Concern
Constant Summary collapse
- GLOBAL_LOGGER =
Concurrent::AtomicReference.new(create_logger(Logger::WARN))
- VERSION =
'0.0.1'
Instance Method Summary collapse
- #create_logger(level = Logger::FATAL, output = $stderr) ⇒ Object
- #logger ⇒ Object
- #logger=(log) ⇒ Object
-
#use_logger(level = Logger::FATAL, output = $stderr) ⇒ Object
Use logger created by #create_logger to log messages.
Instance Method Details
#create_logger(level = Logger::FATAL, output = $stderr) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rogu.rb', line 9 def create_logger(level = Logger::FATAL, output = $stderr) lambda do |severity, progname, = nil, &block| return false if severity < level = block ? block.call : = case when String when Exception format "%s (%s)\n%s", ., .class, (.backtrace || []).join("\n") else .inspect end output.print format "%5s -- %s: %s\n", Logger::SEV_LABEL[severity], progname, true end end |
#logger ⇒ Object
41 42 43 |
# File 'lib/rogu.rb', line 41 def logger GLOBAL_LOGGER.value end |
#logger=(log) ⇒ Object
45 46 47 |
# File 'lib/rogu.rb', line 45 def logger=(log) GLOBAL_LOGGER.value = log end |