Class: Logger
Defined Under Namespace
Modules: Severity Classes: Formatter
Constant Summary collapse
Constants included from Severity
Severity::DEBUG, Severity::ERROR, Severity::FATAL, Severity::INFO, Severity::UNKNOWN, Severity::WARN
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#level ⇒ Object
Returns the value of attribute level.
-
#progname ⇒ Object
Returns the value of attribute progname.
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object
- #debug(progname = nil, &block) ⇒ Object
- #debug? ⇒ Boolean
- #error(progname = nil, &block) ⇒ Object
- #error? ⇒ Boolean
- #fatal(progname = nil, &block) ⇒ Object
- #fatal? ⇒ Boolean
- #info(progname = nil, &block) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(pipe) ⇒ Logger
constructor
A new instance of Logger.
- #unknown(progname = nil, &block) ⇒ Object
- #warn(progname = nil, &block) ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
36 37 38 |
# File 'opal/stdlib/logger.rb', line 36 def formatter @formatter end |
#level ⇒ Object
Returns the value of attribute level.
34 35 36 |
# File 'opal/stdlib/logger.rb', line 34 def level @level end |
#progname ⇒ Object
Returns the value of attribute progname.
35 36 37 |
# File 'opal/stdlib/logger.rb', line 35 def progname @progname end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'opal/stdlib/logger.rb', line 98 def add(severity, = nil, progname = nil, &block) return true if (severity ||= UNKNOWN) < @level progname ||= @progname unless if block_given? = yield else = progname progname = @progname end end @pipe.write(@formatter.call(SEVERITY_LABELS[severity] || 'ANY', ::Time.now, progname, )) true end |
#debug(progname = nil, &block) ⇒ Object
58 59 60 |
# File 'opal/stdlib/logger.rb', line 58 def debug(progname = nil, &block) add DEBUG, nil, progname, &block end |
#error(progname = nil, &block) ⇒ Object
66 67 68 |
# File 'opal/stdlib/logger.rb', line 66 def error(progname = nil, &block) add ERROR, nil, progname, &block end |
#fatal(progname = nil, &block) ⇒ Object
70 71 72 |
# File 'opal/stdlib/logger.rb', line 70 def fatal(progname = nil, &block) add FATAL, nil, progname, &block end |
#info(progname = nil, &block) ⇒ Object
54 55 56 |
# File 'opal/stdlib/logger.rb', line 54 def info(progname = nil, &block) add INFO, nil, progname, &block end |
#unknown(progname = nil, &block) ⇒ Object
74 75 76 |
# File 'opal/stdlib/logger.rb', line 74 def unknown(progname = nil, &block) add UNKNOWN, nil, progname, &block end |