class RemiLib::ConcurrentLogger
- RemiLib::ConcurrentLogger
- RemiLib::Logger
- Reference
- Object
Overview
A ConcurrentLogger
is a fiber-safe and thread-safe Logger
that can
receive messages from multiple fibers.
Defined in:
remilib/logging.crConstant Summary
-
DEFAULT_CHANNEL_SIZE =
2048
-
The default backlog size.
Constructors
-
.new(chanSize : Int, *, ensureNewline : Bool = true, defaultHeader = "", verboseHeader : String = "Note", debugHeader : String = "Debug", warnHeader : String = "Warning", errorHeader : String = "Error", fatalHeader : String = "Fatal", showHeaders : Bool = true)
Creates a new
ConcurrentLogger
instance with a backlog of chanSize. -
.new(*, ensureNewline : Bool = true, defaultHeader = "", verboseHeader : String = "Note", debugHeader : String = "Debug", warnHeader : String = "Warning", errorHeader : String = "Error", fatalHeader : String = "Fatal", showHeaders : Bool = true)
Creates a new
ConcurrentLogger
instance.
Instance Method Summary
-
#dlog(minLevel : UInt8, msg : String)
Prints a message to
#debugStream
if#debugLevel
is greater than or equal tominLevel
. -
#drain : self
Prints all pending messages.
-
#error(msg : String)
Prints a message to
#errorStream
. -
#error(err : Exception)
Prints an exception and its backtrace to
#errorStream
. -
#fatal(msg : String, exitCode = 1) : NoReturn
Prints an error message to
#errorStream
, then callsexit
withexitCode
. -
#fatal(&block : Proc(Tuple(String, Int32))) : NoReturn
Prints an error message to
#errorStream
by callingblock
. -
#fatal(err : Exception, exitCode = 1) : NoReturn
Prints an exception and its backtrace to
#errorStream
, then callsexit
withexitCode
. -
#log(msg : String)
Prints a message to
#defaultStream
. -
#vlog(minLevel : UInt8, msg : String) : Bool
Prints a message to
#defaultStream
if#verbosityLevel
is greater than or equal tominLevel
. -
#warn(msg : String)
Prints a message to
#warnStream
. -
#warn(err : Exception)
Prints an exception and its backtrace to
#warnStream
.
Instance methods inherited from class RemiLib::Logger
<<(text)
<<,
debugColor : Symbol
debugColor,
debugColor=(debugColor : Symbol)
debugColor=,
debugHeader : String
debugHeader,
debugHeader=(debugHeader : String)
debugHeader=,
debugLevel : UInt8
debugLevel,
debugLevel=(debugLevel : UInt8)
debugLevel=,
debugStream : IO
debugStream,
debugStream=(debugStream : IO)
debugStream=,
defaultColor : Symbol
defaultColor,
defaultColor=(defaultColor : Symbol)
defaultColor=,
defaultHeader : String
defaultHeader,
defaultHeader=(defaultHeader : String)
defaultHeader=,
defaultStream : IO
defaultStream,
defaultStream=(defaultStream : IO)
defaultStream=,
dlog(minLevel : UInt8, msg : String)dlog(minLevel : UInt8, &block : Proc(String)) : Bool
dlog(msg : String) : Bool
dlog(&block : Proc(String)) : Bool dlog, dlog!(msg : String) : Bool
dlog!(&block : Proc(String)) : Bool dlog!, ensureNewline=(ensureNewline : Bool) ensureNewline=, ensureNewline? : Bool ensureNewline?, error(msg : String)
error(&block : Proc(String))
error(err : Exception) error, errorColor : Symbol errorColor, errorColor=(errorColor : Symbol) errorColor=, errorHeader : String errorHeader, errorHeader=(errorHeader : String) errorHeader=, errorStream : IO errorStream, errorStream=(errorStream : IO) errorStream=, fatal(msg : String, exitCode = 1) : NoReturn
fatal(&block : Proc(Tuple(String, Int32))) : NoReturn
fatal(err : Exception, exitCode = 1) : NoReturn fatal, fatalHeader : String fatalHeader, fatalHeader=(fatalHeader : String) fatalHeader=, forceFlush=(forceFlush : Bool) forceFlush=, forceFlush? : Bool forceFlush?, log(msg : String)
log(&block : Proc(String)) log, noColors=(noColors : Bool) noColors=, noColors? : Bool noColors?, otherStreams : Array(IO) otherStreams, otherStreams=(otherStreams : Array(IO)) otherStreams=, sanitizeOutput=(sanitizeOutput : Bool) sanitizeOutput=, sanitizeOutput? : Bool sanitizeOutput?, showHeaders=(showHeaders : Bool) showHeaders=, showHeaders? : Bool showHeaders?, timestamp : String timestamp, timestamp=(timestamp : String) timestamp=, trace(msg : String) : Bool
trace(&block : Proc(String)) : Bool trace, verboseColor : Symbol verboseColor, verboseColor=(verboseColor : Symbol) verboseColor=, verboseHeader : String verboseHeader, verboseHeader=(verboseHeader : String) verboseHeader=, verbosityLevel : UInt8 verbosityLevel, verbosityLevel=(verbosityLevel : UInt8) verbosityLevel=, vlog(minLevel : UInt8, msg : String) : Bool
vlog(minLevel : UInt8, &block : Proc(String)) : Bool
vlog(msg : String) : Bool
vlog(&block : Proc(String)) : Bool vlog, warn(msg : String)
warn(&block : Proc(String))
warn(err : Exception) warn, warnColor : Symbol warnColor, warnColor=(warnColor : Symbol) warnColor=, warnHeader : String warnHeader, warnHeader=(warnHeader : String) warnHeader=, warnStream : IO warnStream, warnStream=(warnStream : IO) warnStream=
Constructor methods inherited from class RemiLib::Logger
new(*, ensureNewline : Bool = true, defaultHeader : String = "", verboseHeader : String = "Note", debugHeader : String = "Debug", warnHeader : String = "Warning", errorHeader : String = "Error", fatalHeader : String = "Fatal", showHeaders : Bool = true)
new
Constructor Detail
Creates a new ConcurrentLogger
instance with a backlog of chanSize.
You may want to adjust the chanSize if you experience deadlocks due to an extreme rush of messages right after logger startup, or if you have messages appear before the logger is started.
Creates a new ConcurrentLogger
instance.
Instance Method Detail
Prints a message to #debugStream
if #debugLevel
is greater than or
equal to minLevel
. This always prints a header using #debugHeader
and
#debugColor
.
If #debugLevel
is less than minLevel
, this does nothing.
Returns true
if a message was printed, or false
otherwise.
Prints a message to #errorStream
. This always prints a header using
#errorHeader
and #errorColor
.
Prints an exception and its backtrace to #errorStream
. This always
prints a header using #errorHeader
and #errorColor
.
Prints an error message to #errorStream
, then calls exit
with
exitCode
. This always uses the header "FATAL".
This will override all queued messages.
Prints an error message to #errorStream
by calling block
. The block
must return a tuple consisting of a string (the error message) and an
Int32
(the exit code). This then calls exit
with the exit code
returned by `block. This always uses the header "FATAL".
This will override all queued messages.
Prints an exception and its backtrace to #errorStream
, then calls exit
with exitCode
. This always uses the header "FATAL".
This will override all queued messages.
Prints a message to #defaultStream
. If #defaultHeader
is not an empty
string, then this will first print that header using #defaultColor
.
Prints a message to #defaultStream
if #verbosityLevel
is greater than
or equal to minLevel
. If #verboseHeader
is not an empty string, then
this will first print that header using #defaultColor
.
If #verbosityLevel
is less than minLevel
, this does nothing.
Returns true
if it printed something, or false
otherwise.
Prints a message to #warnStream
. This always prints a header using
#warnHeader
and #warnColor
.
Prints an exception and its backtrace to #warnStream
. This always
prints a header using #warnHeader
and #warnColor
.