Class: Logger
Overview
backtick_javascript: true
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.
38 39 40 |
# File 'opal/stdlib/logger.rb', line 38 def formatter @formatter end |
#level ⇒ Object
Returns the value of attribute level.
36 37 38 |
# File 'opal/stdlib/logger.rb', line 36 def level @level end |
#progname ⇒ Object
Returns the value of attribute progname.
37 38 39 |
# File 'opal/stdlib/logger.rb', line 37 def progname @progname end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'opal/stdlib/logger.rb', line 100 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
60 61 62 |
# File 'opal/stdlib/logger.rb', line 60 def debug(progname = nil, &block) add DEBUG, nil, progname, &block end |
#error(progname = nil, &block) ⇒ Object
68 69 70 |
# File 'opal/stdlib/logger.rb', line 68 def error(progname = nil, &block) add ERROR, nil, progname, &block end |
#fatal(progname = nil, &block) ⇒ Object
72 73 74 |
# File 'opal/stdlib/logger.rb', line 72 def fatal(progname = nil, &block) add FATAL, nil, progname, &block end |
#info(progname = nil, &block) ⇒ Object
56 57 58 |
# File 'opal/stdlib/logger.rb', line 56 def info(progname = nil, &block) add INFO, nil, progname, &block end |
#unknown(progname = nil, &block) ⇒ Object
76 77 78 |
# File 'opal/stdlib/logger.rb', line 76 def unknown(progname = nil, &block) add UNKNOWN, nil, progname, &block end |