Class: ActiveWrapper::Log
- Inherits:
-
Object
- Object
- ActiveWrapper::Log
- Defined in:
- lib/active_wrapper/log.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(options) ⇒ Log
constructor
A new instance of Log.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(options) ⇒ Log
Returns a new instance of Log.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_wrapper/log.rb', line 6 def initialize() @base = [:base] @log = [:log] @stdout = [:stdout] return if @log == false FileUtils.mkdir_p("#{base}/log") file = File.open("#{base}/log/#{log}.log", 'a') file.sync = true if stdout @logger = Logger.new($stdout) $stdout.reopen(file) $stderr.reopen(file) else @logger = Logger.new(file) end ActiveRecord::Base.logger = @logger end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
35 36 37 |
# File 'lib/active_wrapper/log.rb', line 35 def method_missing(method, *args) logger.send(method, *args) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/active_wrapper/log.rb', line 4 def base @base end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
4 5 6 |
# File 'lib/active_wrapper/log.rb', line 4 def log @log end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/active_wrapper/log.rb', line 4 def logger @logger end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/active_wrapper/log.rb', line 4 def stdout @stdout end |
Instance Method Details
#clear ⇒ Object
28 29 30 31 32 33 |
# File 'lib/active_wrapper/log.rb', line 28 def clear Dir["#{base}/log/*.log"].each do |file| f = File.open(file, "w") f.close end end |