Module: ALib::Logging::LogMethods
- Included in:
- ALib::Logging
- Defined in:
- lib/alib-0.4.0/logging.rb
Overview
implementations of the methods shared by both classes and objects of classes which include Logging
Instance Method Summary collapse
-
#__logger_mutex ⇒ Object
–{{{.
-
#__logger_sync ⇒ Object
–}}}.
-
#btrace(e) ⇒ Object
–}}}.
-
#emsg(e) ⇒ Object
–}}}.
-
#errmsg(e) ⇒ Object
–}}}.
- #log_err(e) ⇒ Object
-
#logger ⇒ Object
–}}}.
-
#logger=(log) ⇒ Object
–}}}.
Instance Method Details
#__logger_mutex ⇒ Object
–{{{
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/alib-0.4.0/logging.rb', line 27 def __logger_mutex #--{{{ unless defined?(@__logger_mutex) and @__logger_mutex begin Thread.critical = true @__logger_mutex = Sync::new unless defined?(@__logger_mutex) and @__logger_mutex ensure Thread.critical = false end end @__logger_mutex #--}}} end |
#__logger_sync ⇒ Object
–}}}
40 41 42 43 44 |
# File 'lib/alib-0.4.0/logging.rb', line 40 def __logger_sync #--{{{ __logger_mutex.synchronize{ yield } #--}}} end |
#btrace(e) ⇒ Object
–}}}
88 89 90 91 92 |
# File 'lib/alib-0.4.0/logging.rb', line 88 def btrace e #--{{{ e.backtrace.join("\n") #--}}} end |
#emsg(e) ⇒ Object
–}}}
83 84 85 86 87 |
# File 'lib/alib-0.4.0/logging.rb', line 83 def emsg e #--{{{ "#{ e. } - (#{ e.class })" #--}}} end |
#errmsg(e) ⇒ Object
–}}}
93 94 95 96 97 |
# File 'lib/alib-0.4.0/logging.rb', line 93 def errmsg e #--{{{ emsg(e) << "\n" << btrace(e) #--}}} end |
#log_err(e) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/alib-0.4.0/logging.rb', line 74 def log_err e #--{{{ if logger.debug? error{ errmsg e } else error{ emsg e } end #--}}} end |
#logger ⇒ Object
–}}}
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/alib-0.4.0/logging.rb', line 45 def logger #--{{{ return @logger if defined?(@logger) __logger_sync do unless defined?(@logger) klass = Class === self ? self : self::class self.logger = klass::default_logger end end @logger #--}}} end |