Class: FlogRuby::Flogger
- Inherits:
-
Logger
- Object
- Logger
- FlogRuby::Flogger
- Includes:
- Floggable
- Defined in:
- lib/flog_ruby/logger_factory.rb
Overview
写文件方式
Defined Under Namespace
Classes: Formatter
Instance Attribute Summary collapse
-
#log_path ⇒ Object
Returns the value of attribute log_path.
Instance Method Summary collapse
-
#initialize(logpath, shift_age = 0, shift_size = 1_048_576) ⇒ Flogger
constructor
A new instance of Flogger.
- #logdev ⇒ Object
- #logdev2 ⇒ Object
-
#method_missing(mthd, *margs, &_blk) ⇒ Object
Deprecated!.
Constructor Details
#initialize(logpath, shift_age = 0, shift_size = 1_048_576) ⇒ Flogger
Returns a new instance of Flogger.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/flog_ruby/logger_factory.rb', line 70 def initialize(logpath, shift_age = 0, shift_size = 1_048_576) if logpath if logpath.is_a?(Pathname) logpath.dirname.mkpath @log_path = logpath elsif logpath.is_a?(IO) @log_path = nil else raise "Invalid flog! #{logpath.inspect}" end else raise "Invalid flog! #{logpath.inspect}" end super(logpath, shift_age, shift_size) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mthd, *margs, &_blk) ⇒ Object
Deprecated!
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/flog_ruby/logger_factory.rb', line 95 def method_missing(mthd, *margs, &_blk) self.class.class_eval do define_method mthd do |*args| opts = args. || {} level = opts.delete(:level) || :info send(level, mthd, opts) end end send(mthd, *margs) end |
Instance Attribute Details
#log_path ⇒ Object
Returns the value of attribute log_path.
68 69 70 |
# File 'lib/flog_ruby/logger_factory.rb', line 68 def log_path @log_path end |
Instance Method Details
#logdev ⇒ Object
86 87 88 |
# File 'lib/flog_ruby/logger_factory.rb', line 86 def logdev instance_variable_get('@logdev') end |
#logdev2 ⇒ Object
90 91 92 |
# File 'lib/flog_ruby/logger_factory.rb', line 90 def logdev2 logdev.try(:dev) end |