Fixing data stage spam
Fixing data stage spam
This has been bugging me since the ability to log() during the data stage was added and mostly it's my fault for not accounting for it when it was first added.
Ever since log() was made available during the data stage in Factorio modding mods have been spamming log files. It's so bad that log files end up 10s of thousands of lines adding up to several megabytes worth of useless nothing.
Today while talking with about a bug with another dev it was brought up again and we decided that we want to try to fix it.
My initial plan - unless something better is thought up - is to make log() during data stage do nothing unless you also have --enable-data-log set through the command line. I specifically don't want to make it a config option because it should always be a conscious decision to have it enabled at any point and not something you enable in the config and forget it's enabled.
Another plan (by Bilka): record everything sent through log() during the data stage and if an error is triggered during the data stage or by scenarios then actually write it to the log file. This would also have the --enable-data-log option to force everything to be written instead of buffered.
Ever since log() was made available during the data stage in Factorio modding mods have been spamming log files. It's so bad that log files end up 10s of thousands of lines adding up to several megabytes worth of useless nothing.
Today while talking with about a bug with another dev it was brought up again and we decided that we want to try to fix it.
My initial plan - unless something better is thought up - is to make log() during data stage do nothing unless you also have --enable-data-log set through the command line. I specifically don't want to make it a config option because it should always be a conscious decision to have it enabled at any point and not something you enable in the config and forget it's enabled.
Another plan (by Bilka): record everything sent through log() during the data stage and if an error is triggered during the data stage or by scenarios then actually write it to the log file. This would also have the --enable-data-log option to force everything to be written instead of buffered.
If you want to get ahold of me I'm almost always on Discord.
Re: Fixing data stage spam
I would love a write_file() in the data stage and I wouldn't have to log!
Re: Fixing data stage spam
please add enable-data-log to the config.ini file instead of the command line, true or false.
Re: Fixing data stage spam
This will make mod authors lose viable info when asking for log files from users such as "x mod decided to delete your tile prototypes" which is currently being logged by mod x. For this, and similar "fixing users bugs" reasons, I would prefer to not do the proposed change.
Instead, add something like write file to allow proper debugging without log(), or even a special debug log function that needs the command line parameter that you describe. In the end, you cannot change shitty mods/mod authors that spam logs, they will/can do the same in the control stage. I'd even say that by adding the command line parameter, you make log() spam completely ignorable to mod authors because "it has a command line option". So anyone who has the option on will have even worse log files than before. The annoying overuse of log_debug and ""informational asserts"" in the source code is an example of that dynamic.
Instead, add something like write file to allow proper debugging without log(), or even a special debug log function that needs the command line parameter that you describe. In the end, you cannot change shitty mods/mod authors that spam logs, they will/can do the same in the control stage. I'd even say that by adding the command line parameter, you make log() spam completely ignorable to mod authors because "it has a command line option". So anyone who has the option on will have even worse log files than before. The annoying overuse of log_debug and ""informational asserts"" in the source code is an example of that dynamic.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: Fixing data stage spam
Maybe write log() to another file(like factorio-current-mods.log) when the game is running and when the game closes/crashes add the log file to the end of the factorio-current.log file. That way the log is still part of the factorio-current.log file but you don't have to look at it unless you scroll down to it. Why append the log to the end of the file? Because uploading two different files is apparently more difficult than uploading one(always assume the end user is stupid) and a mod author may need it to fix any issues with the mod.
Waste of bytes : P
Re: Fixing data stage spam
We have script-output folder, why we cannot write the log here?
It makes vanilla log file much lighter and in this way we can make mod parts semi-automatically, for example export locale draft to the file, that can be used as draft for locale for this mod.
It makes vanilla log file much lighter and in this way we can make mod parts semi-automatically, for example export locale draft to the file, that can be used as draft for locale for this mod.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Fixing data stage spam
People will put that into batch files, shortcuts, or steam command line options when the first mod author asks them to do it and then forget about it anyway.Rseding91 wrote: ↑Sun Jun 02, 2019 10:28 pm My initial plan - unless something better is thought up - is to make log() during data stage do nothing unless you also have --enable-data-log set through the command line. I specifically don't want to make it a config option because it should always be a conscious decision to have it enabled at any point and not something you enable in the config and forget it's enabled.
What if someone just wants to look at their mod log without any error happening? Besides it's unexpected behavior to have the log suddenly appear from "nowhere". And the order would probably look weird in a terminal.Rseding91 wrote: ↑Sun Jun 02, 2019 10:28 pm Another plan (by Bilka): record everything sent through log() during the data stage and if an error is triggered during the data stage or by scenarios then actually write it to the log file. This would also have the --enable-data-log option to force everything to be written instead of buffered.
This, for so many reasons. Writefile should just be always accessible globally in all stages. Having it only *inside* of events is a major limitation. It's not a complete replacement for logging though, when i tell users "send me the log" i don't want to teach them how to find yet another file buried somewhere in /script-output.
+1000000Bilka wrote: ↑Mon Jun 03, 2019 1:07 am This will make mod authors lose viable info when asking for log files from users such as "x mod decided to delete your tile prototypes" which is currently being logged by mod x. For this, and similar "fixing users bugs" reasons, I would prefer to not do the proposed change.
The only point i have logging enabled at all in user-builds is bug fixing. I even added a mod-setting to only enable full logging if something really bad happens, and by default it only logs important things. On my dev-build i don't even use log but print() instead. But obviously i can't ask users to run with an attached terminal.
+1. Just split it off if you don't want it, but don't kill it for everyone else. Or you could just mark mod made log() entries with some (possibly invisible) control character so you can easily RegEx delete them.keyboardhack wrote: ↑Mon Jun 03, 2019 1:24 am Maybe write log() to another file(like factorio-current-mods.log)
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.
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Fixing data stage spam
+1.Bilka wrote: ↑Mon Jun 03, 2019 1:07 am This will make mod authors lose viable info when asking for log files from users such as "x mod decided to delete your tile prototypes" which is currently being logged by mod x. For this, and similar "fixing users bugs" reasons, I would prefer to not do the proposed change.
Instead, add something like write file to allow proper debugging without log(), or even a special debug log function that needs the command line parameter that you describe. In the end, you cannot change shitty mods/mod authors that spam logs, they will/can do the same in the control stage. I'd even say that by adding the command line parameter, you make log() spam completely ignorable to mod authors because "it has a command line option". So anyone who has the option on will have even worse log files than before. The annoying overuse of log_debug and ""informational asserts"" in the source code is an example of that dynamic.
Re: Fixing data stage spam
And often enough I wondered about something mid game and switched to looking at the logs. Now I have to save the game, quit, start with --enable-logs, load the game, hope the bug still or again happens and then remember to start factorio without --enable-logs again next time.
I like the suggestion to log mod output to individual files per mod.
I like the suggestion to log mod output to individual files per mod.
Re: Fixing data stage spam
Why not do this?
This way, any log() output is bracketed in the data stage so you can collapse the brackets in your text editor or whatever else you use.
EDIT: Won't solve the 10 MB file issue though.
Perhaps have a limit on how much log output a single mod is allowed to do in the data stage and use your aforementioned command line switch to remove the limit.
Code: Select all
...
Data stage:
{
log()
log()
log()
log()
log()
log()
...
}
EDIT: Won't solve the 10 MB file issue though.
Perhaps have a limit on how much log output a single mod is allowed to do in the data stage and use your aforementioned command line switch to remove the limit.
Re: Fixing data stage spam
Mods spamming the log file are annoying for sure, but any solution to that would also hit responsible mod authors who deactivate logging for their release builds. Also, out of curiosity: why is it only data-stage spam that you are worried about and not control stage logging?
If you do change it, I vote for one separate log file for mods (e.g. factorio-current-mod.log).
If you do change it, I vote for one separate log file for mods (e.g. factorio-current-mod.log).
Re: Fixing data stage spam
While mod authors can use LuaGameScript.write_file for big data.
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Fixing data stage spam
Data stage spam is incredibly common (people just log data.raw or portions of it). Runtime control.lua logging doesn't have a super easy huge table to log and so (so far) hasn't been a problem.
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Fixing data stage spam
If that is the main problem an always-available write_file() sounds like the best solution. "People" would migrate on their own because the data dump would be much easier to read without the log decorations.
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: Fixing data stage spam
log() is also simpler to write. No file name, no append flag, so trivial that you don't need to look up documentation, shorter name and less to write when you just want to quickly debug something and dump some data. Just wrap the x in log() and you can see its value. And then they forget to remove it or don't care.eradicator wrote: ↑Wed Jun 05, 2019 7:57 am
If that is the main problem an always-available write_file() sounds like the best solution. "People" would migrate on their own because the data dump would be much easier to read without the log decorations.
Maybe make log write to the mods own log file and introduce a new function that lets us actually log to factorio-current.log with a much longer name. Something like
Code: Select all
log_to_factorio_current_but_only_for_critical_information_and_not_for_data_dumps_and_remember_to_remove_any_needless_use_of_it_for_release_or_Rseding91_will_be_disappointed()
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Fixing data stage spam
When I need to track errors between LTN and mods subscribing to LTN events having each write to a separate file makes it incredibly hard to get a full picture of what went on.
The same is true for 3rd or 4th degree mods patching another in data stage.
If anything we'd need to log more to get a complete picture. We will end up with every single of these mods dumping data.raw before and after they are done, maybe even several times in between.
Even 10MB for factorio-current.log can be compressed to some kB in an archive. The disk IO of each mod dumping everything into its own file on the other had will get insane.
Instead of making life harder on responsible authors add a way to get rid of crappy mods. Could be as simple as adding a thumbs up/down button in the portal and in game so we can vote badly written mods out.
The same is true for 3rd or 4th degree mods patching another in data stage.
If anything we'd need to log more to get a complete picture. We will end up with every single of these mods dumping data.raw before and after they are done, maybe even several times in between.
Even 10MB for factorio-current.log can be compressed to some kB in an archive. The disk IO of each mod dumping everything into its own file on the other had will get insane.
Instead of making life harder on responsible authors add a way to get rid of crappy mods. Could be as simple as adding a thumbs up/down button in the portal and in game so we can vote badly written mods out.
Last edited by Optera on Wed Jun 05, 2019 10:17 am, edited 1 time in total.
My Mods: mods.factorio.com
Re: Fixing data stage spam
Is it possible to use it as log(data, filename)? It can be same Factorio/factorio-current.log or if filename is not nil then Factorio/logs/filename.log
Re: Fixing data stage spam
The voting "like-dislike" is the worst solution to get the mod authors right feedback. It's always better to write a message and say what is actually goes wrong with his mod.
If someone has made the first version and it was not good enough, he can make update and it works perfectly. Are old dislikes can give the right information about mod quality?
How many mods was perfect by first release?