Hi!
The way the log works is you create a log at the top of the file, and then you have to specify the level of the log, and then listen to that log’s level in your users settings.
Ex:
local log = radiant.log.create_logger(‘my_log_name’)
local MyClass = class()
function MyClass:func(arg_1)
log:detail(“calling func with arg_1: %s”, arg_1)
end
THEN, in your user_settings.json, add a logging section
"logging" : {
“mods” : {
“my_mod” : {
“my_log_name”: 9
}
}
}
The log level numbers are:
ERROR = 1,
WARNING = 3,
INFO = 5,
DEBUG = 7,
DETAIL = 8,
SPAM = 9,
The number you put into your user_settings.json file is the highest log level that will be printed out into stonehearth.log. Ex: putting the number 9 means you’ll get all errors, warnings, info, debug, detail, and spam. Meanwhile, putting 3 means you’ll only get errors and warnings.
Hope this helps
Let me know if you run into any issues.
-Yang
So if it doesn’t work for you, it might be related to the user setting registration for that log. I know based on which function is used to write out the log statement, the registration in user settings will change. Can you paste the line that creates the log and your user settings file?
Thank you, Yang! I actually sent you a PM yesterday with that information, so you might still have it there. I was trying to write from the main Stonehearth mod. I’ve since separated my mod into an smod, which can be found here, along with the relevant user_settings and lua code: