During startup: 01-config.lua:5: attempt to index field 'level' (a nil value) #2

Open
opened 2023-04-09 00:05:26 +00:00 by AliasAlreadyTaken · 2 comments

I must admit I have a hard time reading this part, the logging

When sending the content of watchtower.logger to the log via core.log("action","watchtower.logger="..dump(watchtower.logger)) I get an empty table

That leads to this crash during startup:

2023-04-08 23:58:45: ACTION[Main]: [MOD] watchtower loading
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Trace] Trace message
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Debug] debug message
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Info] info message
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Warning] warning message
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Error] error message
2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Critical] critical message
[watchtower] [Warning] Print test message
2023-04-08 23:58:45: ACTION[Main]: Server: Shutting down
2023-04-08 23:58:47: ERROR[Main]: ModError: Failed to load and run script from /home/mt/5.6.1/Minetest_test/bin/../worlds/Minetest_test/worldmods/watchtower/init.lua:
2023-04-08 23:58:47: ERROR[Main]: .../worlds/Minetest_test/worldmods/watchtower/01-config.lua:5: attempt to index field 'level' (a nil value)
2023-04-08 23:58:47: ERROR[Main]: stack traceback:
2023-04-08 23:58:47: ERROR[Main]: 	.../worlds/Minetest_test/worldmods/watchtower/01-config.lua:5: in main chunk
2023-04-08 23:58:47: ERROR[Main]: 	[C]: in function 'dofile'
2023-04-08 23:58:47: ERROR[Main]: 	...in/../worlds/Minetest_test/worldmods/watchtower/init.lua:22: in main chunk

When I edit this line

watchtower.logger.loglevel = minetest.settings:get("watchtower.loglevel") or watchtower.logger.level.INFO

into

watchtower.logger.loglevel = minetest.settings:get("watchtower.loglevel") or "Info"

it loads properly, but I'm not sure if that value is ok. You may want to help users selecting a proper value with the settingtypes.txt mechanic. Unfortunately the yl_template lacked this file at the time of forking and even now only has a slim example: https://gitea.your-land.de/your-land/yl_template/src/branch/master/settingtypes.txt

I must admit I have a hard time reading this part, the logging When sending the content of `watchtower.logger` to the log via core.log("action","watchtower.logger="..dump(watchtower.logger)) I get an empty table That leads to this crash during startup: ``` 2023-04-08 23:58:45: ACTION[Main]: [MOD] watchtower loading 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Trace] Trace message 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Debug] debug message 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Info] info message 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Warning] warning message 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Error] error message 2023-04-08 23:58:45: ACTION[Main]: [watchtower] [Critical] critical message [watchtower] [Warning] Print test message 2023-04-08 23:58:45: ACTION[Main]: Server: Shutting down 2023-04-08 23:58:47: ERROR[Main]: ModError: Failed to load and run script from /home/mt/5.6.1/Minetest_test/bin/../worlds/Minetest_test/worldmods/watchtower/init.lua: 2023-04-08 23:58:47: ERROR[Main]: .../worlds/Minetest_test/worldmods/watchtower/01-config.lua:5: attempt to index field 'level' (a nil value) 2023-04-08 23:58:47: ERROR[Main]: stack traceback: 2023-04-08 23:58:47: ERROR[Main]: .../worlds/Minetest_test/worldmods/watchtower/01-config.lua:5: in main chunk 2023-04-08 23:58:47: ERROR[Main]: [C]: in function 'dofile' 2023-04-08 23:58:47: ERROR[Main]: ...in/../worlds/Minetest_test/worldmods/watchtower/init.lua:22: in main chunk ``` When I edit this line ``` watchtower.logger.loglevel = minetest.settings:get("watchtower.loglevel") or watchtower.logger.level.INFO ``` into ``` watchtower.logger.loglevel = minetest.settings:get("watchtower.loglevel") or "Info" ``` it loads properly, but I'm not sure if that value is ok. You may want to help users selecting a proper value with the settingtypes.txt mechanic. Unfortunately the yl_template lacked this file at the time of forking and even now only has a slim example: https://gitea.your-land.de/your-land/yl_template/src/branch/master/settingtypes.txt
Ravise added the
type
bug
step
at work
labels 2023-04-09 10:27:11 +00:00
Ravise self-assigned this 2023-04-09 10:27:27 +00:00
Owner

Default value of "Info" (string) is not correct. Value from configuration is currently to be a int (number) as declared in values of 00-tooling/logger table. True, this should be changed into symbolic names in future. #4 created to watch this.

I'll make and publish a "integration testing" mod with all sorts of core.log("action","watchtower.logger="..dump(watchtower.logger)) calls in there. I definitely verified the mod is working on my local world... This calls for more runtime abuse of the mod table.

The logger is done in OOP style with logger:new being the factory function.

Empty table in question was caused in 01-config:05 by the level table being nonexistent.

Default value of "Info" (`string`) is not correct. Value from configuration is currently to be a int (`number`) as declared in values of `00-tooling/logger` table. True, this should be changed into symbolic names in future. https://gitea.your-land.de/Ravise/watchtower/issues/4 created to watch this. I'll make and publish a "integration testing" mod with all sorts of `core.log("action","watchtower.logger="..dump(watchtower.logger))` calls in there. I definitely verified the mod is working on my local world... This calls for more runtime abuse of the mod table. The logger is done in OOP style with `logger:new` being the factory function. Empty table in question was caused in `01-config:05` by the `level` table being nonexistent.
Owner

Fix: 35fa0aaa63

Fix: 35fa0aaa63f719ffac974bd581ec7a90278a57de
Ravise added
step
at issuer
and removed
step
at work
labels 2023-04-09 13:04:48 +00:00
Sign in to join this conversation.
No description provided.