Module: ALib::Logging::LogMethods
- Defined in:
- lib/alib-0.5.1/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
(also: #logger!)
–}}}.
- #logger=(log) ⇒ Object
Instance Method Details
#__logger_mutex ⇒ Object
–{{{
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/alib-0.5.1/logging.rb', line 77 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
–}}}
90 91 92 93 94 |
# File 'lib/alib-0.5.1/logging.rb', line 90 def __logger_sync #--{{{ __logger_mutex.synchronize{ yield } #--}}} end |
#btrace(e) ⇒ Object
–}}}
141 142 143 144 145 |
# File 'lib/alib-0.5.1/logging.rb', line 141 def btrace e #--{{{ e.backtrace.join("\n") #--}}} end |
#emsg(e) ⇒ Object
–}}}
136 137 138 139 140 |
# File 'lib/alib-0.5.1/logging.rb', line 136 def emsg e #--{{{ "#{ e. } - (#{ e.class })" #--}}} end |
#errmsg(e) ⇒ Object
–}}}
146 147 148 149 150 |
# File 'lib/alib-0.5.1/logging.rb', line 146 def errmsg e #--{{{ emsg(e) << "\n" << btrace(e) #--}}} end |
#log_err(e) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/alib-0.5.1/logging.rb', line 127 def log_err e #--{{{ if logger.debug? error{ errmsg e } else error{ emsg e } end #--}}} end |
#logger ⇒ Object Also known as: logger!
–}}}
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/alib-0.5.1/logging.rb', line 95 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 |