I noticed a few of you are trying to write to our log. Here’s how.
First, in your lua create a logger and give it tag.
local log = radiant.log.create_logger(‘tag_name’)
To write to the log, invoke methods on the logger
log:info(‘hello world’)
We have multiple levels of logging. Here they are
ERROR = 1
WARNING = 3
INFO = 5
DEBUG = 7
DETAIL = 8
SPAM = 9
All of these have a corresponding method on the logger
log:detail(‘really fine grained logging information’)
log:error(‘OMG CRAZY IMPORTANT ERROR!’)
You probably figured most of that out on your own. Here’s the secret sauce.
To actually show stuff in your log, add a logging block to your user_settings.json
"logging" : {
"show_console" : true,
"mods" : {
"your_mod_name" : {
"log_level" : 1,
"tag_name" : 5
}
}
},
show_console: Pops up a window with the log when the game runs
log_level: The default logging level across the whole mod. This is optional.
tag_name: The logging level for log entries with that tag.
The idea is if you mod as several different logical features, you initialize a separate logger for each of them, with different tags. Then when you’re debugging feature a vs. feature b, you can adjust the logging level in your user settings so your log isn’t spammed with information that you don’t care about.
Examples!
This will log ONLY log:error(‘…’) entries from loggers created with the tag ‘feature a’
"mods" : {
"your_mod_name" : {
"feature_a" : 1
}
}
This will log all log entries from loggers created with the “feature_b” tag.
"mods" : {
"your_mod_name" : {
"feature_b" : 9
}
}
And of course this works
"mods" : {
"your_mod_name" : {
"feature_a" : 1
"feature_b" : 9
}
}