-
Notifications
You must be signed in to change notification settings - Fork 9
Loginator: Examples
For each example below, I will send the same four log entries.
log:error("Something is seriously broken!")
log:warn("Things are minorly borked")
log:info("You might want to know this")
log:debug("Oh god you're digging deep aren't you?!")
So I will only include the code to create the logger with each example, and a screenshot of the html log generated. At the end I will include a couple of ansi and plaintext examples, but they do not have as much to configure.
bgColor and fgColor are html colors, and are written to the header of the file when the file is first created. This means changes to this will not take effect in files which are already started.
levelColors should be c/d/hecho colors (foreground only, no background)
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
bgColor = "orange",
fgColor = "black",
levelColors = {
warn = "blue"
}
})
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
bgColor = "white",
fgColor = "black",
})
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
bgColor = "lightgrey",
fgColor = "black",
levelColors = {
error = "firebrick",
warn = "blue",
info = "brown",
debug = "DarkGreen"
}
})
Level is set to debug so all the messages are written. Besides that and the name everything else is default. This is how I see myself using it most of the time, though probably at 'warn' level.
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
})
Prithee stay a while and listene, thate Ie mighte relate toe thee the Tales ofe Olde.
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
entryTemplate = "In the Year of the Common Era |y, in the |M month on the |d day you stood upon the |c|l|r podium and spake thee: |t",
})
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
entryTemplate = "|y-|M-|d |h:|m:|s.|x [|l] |c|t|r",
})
This is catted in my terminal, which is green on black for 'default' text
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
format = "a"
})
This one opened in my default text editor (gedit as it turns out)
local log = loginator:new({
name = "ExampleLogger",
level = "debug",
format = "p"
})