Is there any way to determine where the debug log is being written?
- sorcerykid
- Member
- Posts: 1841
- Joined: Fri Aug 26, 2016 15:36
- GitHub: sorcerykid
- In-game: Nemo
- Location: Illinois, USA
Is there any way to determine where the debug log is being written?
There is mineteset.get_worldpath and minetest.get_modpath(), but what about getting the path of "debug.txt" or for that matter even "minetest.conf"? Is this even possible from within a mod? Or is there some type of workaround that correctly accounts for these being supplied on the command line, or otherwise falling back to their corresponding default paths?
-
- Member
- Posts: 155
- Joined: Mon Dec 28, 2020 01:19
- GitHub: loosewheel
- In-game: loosewheel
Re: Is there any way to determine where the debug log is being written?
I don't know about getting the path of them, but it doesn't look like you can do anything with them anyway:
Errored out with:
Unless there is a setting in the engine to allow it.
Code: Select all
local f = io.open (minetest.get_worldpath ().."/../../debug.txt", "r")
if f then
print ("debug -----------------", f:read ("*l"))
f:close ()
else
print ("no debug --------------------------")
end
Code: Select all
ModError: Failed to load and run script from /home/loosewheel/.minetest/mods/lwexport_tools/init.lua:
Mod security: Blocked attempted read from /home/loosewheel/.minetest/worlds/lwcopy/../../debug.txt
stack traceback:
[C]: in function 'open'
/home/loosewheel/.minetest/mods/lwexport_tools/init.lua:36: in main chunk
Check debug.txt for details.
- sorcerykid
- Member
- Posts: 1841
- Joined: Fri Aug 26, 2016 15:36
- GitHub: sorcerykid
- In-game: Nemo
- Location: Illinois, USA
Re: Is there any way to determine where the debug log is being written?
I'm not intending to read these files, but rather to check the filesystem at regular intervals to determine if there is sufficient free space. The "df" command (at least on Red Hat Linux) accepts a path to a file.
Anyway, I simply implemented a new API function in the engine: minetest.get_system_path() that takes the name of a system file, and returns the corresponding path to the file.
Provides the following output:
Anyway, I simply implemented a new API function in the engine: minetest.get_system_path() that takes the name of a system file, and returns the corresponding path to the file.
Code: Select all
local debug_path = minetest.get_system_path( "debug.txt" )
os.execute( string.format( "df -B MB --direct '%s'", debug_path ) )
Code: Select all
Filesystem 1MB-blocks Used Available Use% File
- 922728MB 868568MB 7281MB 100% /home/minetest/.minetest/test.log
- Blockhead
- Member
- Posts: 1622
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Is there any way to determine where the debug log is being written?
It's possible without an engine change to monitor the size of the debug log file, under Linux and assuming a constant file descriptor number. I seem to always get minetest's debug log file as fd number 3 on my Debian system, and it's probably pretty stable across distributions. Assuming you're only running one minetest process, to check if the log file is what you expect, run:
ls -l /proc/$(pgrep minetest)/fd/3
You should get ~/.minetest/debug.log or whatever you provided on the command line.
Then to monitor the file's size it you can run:
du /proc/$(pgrep minetest)/fd/3
or use df for the entire volume similar to how you specified:
df -B MB /proc/$(pgrep minetest)/fd/3
I'm not sure what --direct does, it's not on my Debian version of df.
Your mileage may vary, no warranty et cetera :)
ls -l /proc/$(pgrep minetest)/fd/3
You should get ~/.minetest/debug.log or whatever you provided on the command line.
Then to monitor the file's size it you can run:
du /proc/$(pgrep minetest)/fd/3
or use df for the entire volume similar to how you specified:
df -B MB /proc/$(pgrep minetest)/fd/3
I'm not sure what --direct does, it's not on my Debian version of df.
Your mileage may vary, no warranty et cetera :)
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
Who is online
Users browsing this forum: No registered users and 4 guests