Second argument to log (and maybe print): options
Second argument to log (and maybe print): options
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
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
I have mods! I guess!
Link
Link
-
- Filter Inserter
- Posts: 302
- Joined: Fri Mar 18, 2016 4:34 pm
- Contact:
Re: Second argument to log (and maybe print): options
print is already vararg, it prints all the args.
Re: Second argument to log (and maybe print): options
It would be nice if the argument can disable the text before the logged string or will be changeable.
For example gives:
For example
Code: Select all
log("my logged text", {prefix = mod_name .. "_" .. mod_version .. ": "})
Code: Select all
MyMod_0.0.1: my logged text
Re: Second argument to log (and maybe print): options
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.
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.
If you want to get ahold of me I'm almost always on Discord.
Re: Second argument to log (and maybe print): options
My log file after just game load is about 50 MB, while I cannot save the needed information in another place.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.
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
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.darkfrei wrote: Fri Feb 14, 2020 2:55 pmMy log file after just game load is about 50 MB, while I cannot save the needed information in another place.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.
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.
I have mods! I guess!
Link
Link
-
- Filter Inserter
- Posts: 302
- Joined: Fri Mar 18, 2016 4:34 pm
- Contact:
Re: Second argument to log (and maybe print): options
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
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.justarandomgeek wrote: Fri Feb 14, 2020 4:00 pmso... exactly what you're not supposed to do with it? dumping large amounts of data?
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Second argument to log (and maybe print): options
Why does this suddenly have a new thread, and what happend to the idea of data stage write_file()?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Second argument to log (and maybe print): options
I did see the thread from ~6 months ago: viewtopic.php?t=71506 unless you meant something else.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()?
My goal isn't writing to script-output in the data stage, it is reducing/customizing log prints.
I have mods! I guess!
Link
Link
Re: Second argument to log (and maybe print): options
I'm almost scared to ask what kind of data dumps you do during data stage.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 theCode: Select all
log (string, {script_output = true})
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.
My Mods: mods.factorio.com
Re: Second argument to log (and maybe print): options
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:
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)