ent = require "ent"
function love.load()
-- create the logfile & writer thread
ent.init()
end
function love.keypressed(key)
-- log keypresses from the player
ent.echo(key)
end
function love.quit()
-- close the logfile & writer thread
ent.close()
end
The main caveat to using Ent is by design - only 1 log file can be created per session. This is to emphasise ease of use (no need to be juggling filenames).
Another thing to note is that the output functions are created dynamically from the configured log levels. By default it comes with 7 levels which can be accessed as such:
All ouput functions use the same signature as `string.format` and will perform the formatting. The output will have the timestamp and log level prepended to the input.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
KayleMaster wrote: ↑Thu Jan 13, 2022 8:59 pm
Looks great! Probably time to replace my print statements.
Can I request a feature?
Hey KayleMaster, thanks for your interest. Regarding your question, you can already do this by providing custom log levels. You can pass in a table to override the defaults with the init function. Each log level entry should be a table with 2 strings: the level lable, and a hex colour for HTML output. Ent will generate a function using the key of the table in the log levels table.
local ent = require "ent"
local logLevels =
{
-- these are the defaults
echo = {"Echo", "#aaaaaa"},
info = {"Info", "#2288dd"},
warn = {"Warning", "#dddd22"},
error = {"Error!", "#ff44aa"},
edit = {"Editor", "#88ddbb"},
client = {"NetClient", "#aaaaaa"},
server = {"NetServer", "#aaaaaa"},
-- custom levels
map = {"Map", "#ff8833"}
}
ent.init {logLevels = logLevels}
ent.map "Chocolate cake" -- will output "[00:00:00:00] (Map) Chocolate cake" in blueish text
--these also work
ent.info "Lemon cake"
ent.error "Bacon cake"
--etc
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
KayleMaster wrote: ↑Fri Jan 14, 2022 4:44 pm
That will work for me, although I was thinking of in conjuction with log levels. That being said, I think this is the better option anyways. Thanks!
No worries. Thanks for the feedback
Do let me know if you have any more suggestions or if you encounter any issues - feel free to file a ticket on github.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.