Import std.log.logger
std.log.logger
Logger, which writes a module's lines, with levels and fields.
Logger, which writes lines for a module at levels, with fields, to a LogOutput: the default one, which writes readable lines to stderr at the levels FB_LOG sets, or one the program makes, with sinks of its own. Loggers and LogOutputs are Shared Classes, so any thread can log, and a Logger with a field is a new Logger, so threads never change one another's.
std/log/logger.fb
Types
Logger
class
Public Shared Class Logger
Writes lines for a module, with the fields it's given, at levels, to an output. Its Trace, Debug, Info, Warn, and Error write a line at their level, when the output's filter writes that level for the module.
Examples
Const lines = Channel<String>(8)
Function Keep(line: String)
lines.Send(line)
End Function
Local output = LogOutput(LogFilter.At(LogLevel.INFO))
output.Add(JsonLinesSink(Keep))
Local log = Logger("shop", output).With("user", "ada")
log.Debug("not written, as DEBUG is below INFO")
log.Info("signed in")
Local line = lines.TryReceive() ?? ""
Expect(line.Contains("\"message\":\"signed in\"") && line.Contains("\"user\":\"ada\""))
Expect(lines.TryReceive() == Null)-
A Logger for
module, a name like "net.http" whose dots say what it's in, which writes to the default output. -
A Logger for
modulethat writes tooutput. -
The module it writes for.
-
The fields each of its lines has, in the order they were given.
-
A Logger like this one whose lines have the field too, after its others.
-
A Logger whose lines have the field
name, ofvalue's number, beside this one's: each of the eight integer types has one. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number, beside this one's. -
A Logger whose lines have the field
name, ofvalue's number. A Double that isn't finite is text, since JSON has no number for it: "inf", "-inf", or "nan", whatever a NaN's sign bit. -
A Logger whose lines have the field
name, true or false, beside this one's. -
Whether a line at
levelwould be written, so code can leave out work that only a line would use. -
Writes
messageatlevel, now, when the output's filter writes it. -
Writes
messageat TRACE, as Log does. -
Writes
messageat DEBUG, as Log does. -
Writes
messageat INFO, as Log does. -
Writes
messageat WARN, as Log does. -
Writes
messageat ERROR, as Log does.
Functions
DefaultLogOutput
function
Public Function DefaultLogOutput(): LogOutput
The default output, made the first time a Logger uses it: the console's sink, at the levels FB_LOG sets, or at INFO when it isn't set. An FB_LOG that isn't a filter is said once on stderr, and left out.
Examples
Local output = DefaultLogOutput()
// FB_LOG sets its levels, INFO without it, and an ERROR is written but where it's off.
Expect(output == DefaultLogOutput())Report an issue with this page or with FutureBlitz on GitHub.