Class: SmartProxyDynflowCore::Log
- Inherits:
-
Logger
- Object
- Logger
- SmartProxyDynflowCore::Log
- Defined in:
- lib/smart_proxy_dynflow_core/log.rb
Defined Under Namespace
Classes: ProxyAdapter
Class Method Summary collapse
- .instance ⇒ Object
- .instance=(logger) ⇒ Object
- .log_file ⇒ Object
- .log_level ⇒ Object
- .reload! ⇒ Object
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #handle_log_rolling ⇒ Object
-
#initialize(file, *rest) ⇒ Log
constructor
A new instance of Log.
- #roll_log ⇒ Object
Constructor Details
#initialize(file, *rest) ⇒ Log
Returns a new instance of Log.
43 44 45 46 47 48 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 43 def initialize(file, *rest) @file = file @fd = @file.kind_of?(IO) ? @file : File.open(@file, 'a') @fd.sync = true super(@fd, rest) end |
Class Method Details
.instance ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 9 def instance if @logger.nil? @logger = self.new log_file @logger.level = log_level end @logger end |
.instance=(logger) ⇒ Object
17 18 19 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 17 def instance=(logger) @logger = logger end |
.log_file ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 34 def log_file if Settings.instance.loaded && Settings.instance.log_file Settings.instance.log_file else $stdout end end |
.log_level ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 26 def log_level if Settings.instance.loaded && Settings.instance.log_level ::Logger.const_get(Settings.instance.log_level.upcase) else Logger::WARN end end |
.reload! ⇒ Object
21 22 23 24 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 21 def reload! @logger = nil instance end |
Instance Method Details
#add(*args) ⇒ Object
50 51 52 53 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 50 def add(*args) handle_log_rolling if @roll_log super(*args) end |
#handle_log_rolling ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 59 def handle_log_rolling @roll_log = false unless @file.kind_of? IO @fd.reopen @file, 'a' @fd.sync = true end end |
#roll_log ⇒ Object
55 56 57 |
# File 'lib/smart_proxy_dynflow_core/log.rb', line 55 def roll_log @roll_log = true end |