Class: RubyApp::Log
- Inherits:
-
Logger
- Object
- Logger
- RubyApp::Log
- Extended by:
- Mixins::ConfigurationMixin, Mixins::DelegateMixin
- Defined in:
- lib/ruby_app/log.rb
Defined Under Namespace
Classes: Formatter
Class Method Summary collapse
Instance Method Summary collapse
- #duration(severity, message) ⇒ Object
- #exception(severity, exception) ⇒ Object
- #memory(severity, message) ⇒ Object
Methods included from Mixins::ConfigurationMixin
Methods included from Mixins::DelegateMixin
Class Method Details
.close! ⇒ Object
70 71 72 73 74 75 |
# File 'lib/ruby_app/log.rb', line 70 def self.close! if @@_log ||= nil @@_log.close @@_log = nil end end |
.get ⇒ Object
58 59 60 |
# File 'lib/ruby_app/log.rb', line 58 def self.get ( @@_log ||= nil ) || ( @@_standard_log ||= RubyApp::Log.new($stdout) ) end |
Instance Method Details
#duration(severity, message) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ruby_app/log.rb', line 25 def duration(severity, ) start = Time.now begin return yield ensure self.log(severity, "#{} #{Time.now - start}s") end end |
#exception(severity, exception) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/ruby_app/log.rb', line 44 def exception(severity, exception) self.log(severity, '-' * 80) self.log(severity, "exception=#{exception.class.inspect} #{exception.}") self.log(severity, '-' * 80) exception.backtrace.each do |line| self.log(severity, line) end self.log(severity, '-' * 80) end |
#memory(severity, message) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby_app/log.rb', line 34 def memory(severity, ) begin return yield ensure GC.start count = ObjectSpace.each_object { |item| } self.log(severity, "#{} count=#{count}") end end |