Class: SiteFuel::SiteFuelLogger
- Inherits:
-
Logger
- Object
- Logger
- SiteFuel::SiteFuelLogger
- Includes:
- Singleton
- Defined in:
- lib/sitefuel/SiteFuelLogger.rb
Overview
Singleton abstraction around the Logger |
library, typically every processor |
will hook into using this logger while letting us control it's placement and display globally
Instance Attribute Summary (collapse)
-
- (Object) debug_count
readonly
the number of debug messages logged so far (even if lower than #level).
-
- (Object) error_count
readonly
the number of error messages logged so far (even if lower than #level).
-
- (Object) fatal_count
readonly
the number of fatal messages logged so far (even if lower than #level).
-
- (Object) info_count
readonly
the number of info messages logged so far (even if lower than #level).
-
- (Object) log_style
adjust the style of logging:.
-
- (Object) warn_count
readonly
the number of warning messages logged so far (even if lower than #level).
Instance Method Summary (collapse)
- - (Object) debug(*args)
- - (Object) error(*args)
- - (Object) fatal(*args)
-
- (Object) format_message(severity, date_time, program_name, msg)
implement our own #add so we can have cleaner logs.
- - (Object) info(*args)
-
- (SiteFuelLogger) initialize(filename = STDOUT)
constructor
A new instance of SiteFuelLogger.
- - (Object) warn(*args)
Constructor Details
- (SiteFuelLogger) initialize(filename = STDOUT)
A new instance of SiteFuelLogger
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 44 def initialize(filename = STDOUT) super(filename) @fatal_count = 0 @error_count = 0 @warn_count = 0 @info_count = 0 @debug_count = 0 self.level = WARN @log_style = :default @progname = 'SiteFuel' end |
Instance Attribute Details
- (Object) debug_count (readonly)
the number of debug messages logged so far (even if lower than #level)
35 36 37 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 35 def debug_count @debug_count end |
- (Object) error_count (readonly)
the number of error messages logged so far (even if lower than #level)
26 27 28 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 26 def error_count @error_count end |
- (Object) fatal_count (readonly)
the number of fatal messages logged so far (even if lower than #level)
23 24 25 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 23 def fatal_count @fatal_count end |
- (Object) info_count (readonly)
the number of info messages logged so far (even if lower than #level)
32 33 34 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 32 def info_count @info_count end |
- (Object) log_style
adjust the style of logging:
default |
use the Logger logging style |
clean |
gives a clean logging output intended for human use |
41 42 43 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 41 def log_style @log_style end |
- (Object) warn_count (readonly)
the number of warning messages logged so far (even if lower than #level)
29 30 31 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 29 def warn_count @warn_count end |
Instance Method Details
- (Object) debug(*args)
83 84 85 86 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 83 def debug(*args) @debug_count += 1 super(*args) end |
- (Object) error(*args)
65 66 67 68 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 65 def error(*args) @error_count += 1 super(*args) end |
- (Object) fatal(*args)
59 60 61 62 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 59 def fatal(*args) @fatal_count += 1 super(*args) end |
- (Object) format_message(severity, date_time, program_name, msg)
implement our own #add so we can have cleaner logs
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 90 def (severity, date_time, program_name, msg) case @log_style when :default super(severity, date_time, program_name, msg) when :clean string = "#{severity}: #{msg}\n" case severity when 'ERROR', 'FATAL' string = bold(red(string)) when 'WARN' string = yellow(string) when 'INFO', 'DEBUG' string = dark(string) end string end end |
- (Object) info(*args)
77 78 79 80 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 77 def info(*args) @info_count += 1 super(*args) end |
- (Object) warn(*args)
71 72 73 74 |
# File 'lib/sitefuel/SiteFuelLogger.rb', line 71 def warn(*args) @warn_count += 1 super(*args) end |