Page 1 of 1

Second argument to log (and maybe print): options

Posted: Sat Feb 08, 2020 5:29 pm
by Honktown
Currently log always prints exactly the same information, and it can get annoying not getting a "clean" print. The closest one can get is adding "\n" at the start* of a string to force it to the next line.

With options, I can think of a few examples:
source = boolean, print the file (debug.getinfo(1).source)
time = boolean, print the decimal bit at the beginning (formatted ctime?)
tick = boolean, print the game tick (after the time, empty quotes or "-1" for outside control phase)

for extra coverage:
line = boolean, print the line number
name = boolean, the function name, number, or nil if anonymous, similar to debug.getinfo(1).name

Re: Second argument to log (and maybe print): options

Posted: Thu Feb 13, 2020 7:02 am
by justarandomgeek
print is already vararg, it prints all the args.

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 7:51 am
by darkfrei
It would be nice if the argument can disable the text before the logged string or will be changeable.

For example

Code: Select all

log("my logged text", {prefix = mod_name .. "_" .. mod_version .. ": "})
gives:

Code: Select all

MyMod_0.0.1:  my logged text

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 1:56 pm
by Rseding91
Well I can see the desire, ideally mods should just not be using logging in the majority of the cases. Really logging is meant for errors and debug info. In both of those cases you want all of what's included in logging now.

Logging is not meant to ever get to the modded minecraft levels of log spam where after a 2 hour play session you have a 16 MB log file.

I've thought a few times about some log-spam-detection system for mods that would auto-cull a mods ability to log if it detected they were spamming the log file. Because it already happens and we see it in crash reports all the time and I hate it.

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 2:55 pm
by darkfrei
Rseding91 wrote:
Fri Feb 14, 2020 1:56 pm
Logging is not meant to ever get to the modded minecraft levels of log spam where after a 2 hour play session you have a 16 MB log file.

I've thought a few times about some log-spam-detection system for mods that would auto-cull a mods ability to log if it detected they were spamming the log file. Because it already happens and we see it in crash reports all the time and I hate it.
My log file after just game load is about 50 MB, while I cannot save the needed information in another place.

It would be nice to save the mod log into the script_output folder just with the

Code: Select all

log (string, {script_output = true})

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 3:01 pm
by Honktown
darkfrei wrote:
Fri Feb 14, 2020 2:55 pm
Rseding91 wrote:
Fri Feb 14, 2020 1:56 pm
Logging is not meant to ever get to the modded minecraft levels of log spam where after a 2 hour play session you have a 16 MB log file.

I've thought a few times about some log-spam-detection system for mods that would auto-cull a mods ability to log if it detected they were spamming the log file. Because it already happens and we see it in crash reports all the time and I hate it.
My log file after just game load is about 50 MB, while I cannot save the needed information in another place.
Not to be a bother, but what are you logging!?! I normally don't have everything print "fully", I leave the irrelevant log()s commented unless I'm debugging specifically something. Even data.raw is less than 10MB... unless one installs 100 mods.

Only thing I could think with Rseding is go yell at the bad mod authors... making it difficult for the good ones is not the option I would prefer (normally when I have a mod "ready" the only thing that should ever print are errors - which may not print anyway if the game errors first). I do have one mod that logs "a lot" in one step in the data stage, I can add an option for that.

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 3:05 pm
by darkfrei
Honktown wrote:
Fri Feb 14, 2020 3:01 pm
Not to be a bother, but what are you logging!?!
Some mods + viewtopic.php?t=45107

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 4:00 pm
by justarandomgeek
darkfrei wrote:
Fri Feb 14, 2020 3:05 pm
Honktown wrote:
Fri Feb 14, 2020 3:01 pm
Not to be a bother, but what are you logging!?!
Some mods + viewtopic.php?t=45107
so... exactly what you're not supposed to do with it? dumping large amounts of data?

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 4:06 pm
by darkfrei
justarandomgeek wrote:
Fri Feb 14, 2020 4:00 pm
darkfrei wrote:
Fri Feb 14, 2020 3:05 pm
Some mods + viewtopic.php?t=45107
so... exactly what you're not supposed to do with it? dumping large amounts of data?
I want dump what I need to dump, but I want that this dump doesn't hurt Rseding91 with the huge size of log file. The suggested second argument can really help in this situation.

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 4:20 pm
by eradicator
Why does this suddenly have a new thread, and what happend to the idea of data stage write_file()?

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 7:41 pm
by Honktown
eradicator wrote:
Fri Feb 14, 2020 4:20 pm
Why does this suddenly have a new thread, and what happend to the idea of data stage write_file()?
I did see the thread from ~6 months ago: viewtopic.php?t=71506 unless you meant something else.

My goal isn't writing to script-output in the data stage, it is reducing/customizing log prints.

Re: Second argument to log (and maybe print): options

Posted: Fri Feb 14, 2020 8:31 pm
by Optera
darkfrei wrote:
Fri Feb 14, 2020 2:55 pm
My log file after just game load is about 50 MB, while I cannot save the needed information in another place.

It would be nice to save the mod log into the script_output folder just with the

Code: Select all

log (string, {script_output = true})
I'm almost scared to ask what kind of data dumps you do during data stage.
Only way I ever get to those two digit MB levels is through running LTN in debug mode for a while.

For data dump shenanigans I can see merit in writing to a different file.

Re: Second argument to log (and maybe print): options

Posted: Mon Feb 17, 2020 11:31 am
by Helfima
I made a debugger which writes only if it is active
it accepts a list of parameters
you can get inspired
https://github.com/Helfima/helmod/blob/ ... ogging.lua
Sample:

Code: Select all

Logging:debug(ModelCompute.classname, "lua_ingredient.name", lua_ingredient.name, "nextCount=", nextCount)