What better use for logging in the plugin?
Loggers or logging or something else?
Logging
Ideally, you would want to use loggers. Though, we obviously haven't added any of that to the wiki, yet. Here is GunGame's usage of LogManager:
https://github.com/GunGame-Dev-Team/GunGame-SP/blob/master/addons/source-python/plugins/gungame/core/logger.py
The reason why ConVars are used for level and areas is so that server operators (and plugin testers) can easily change where the messages are logged to and which messages to log. For more information on the two types of variables, look to the ../cfg/source-python/core_settings.ini's LOG_SETTINGS section:
https://github.com/GunGame-Dev-Team/GunGame-SP/blob/master/addons/source-python/plugins/gungame/core/logger.py
The reason why ConVars are used for level and areas is so that server operators (and plugin testers) can easily change where the messages are logged to and which messages to log. For more information on the two types of variables, look to the ../cfg/source-python/core_settings.ini's LOG_SETTINGS section:
Syntax: Select all
[LOG_SETTINGS]
# Set to the logging level to use for Source.Python.
# To show all messages, set to level 5.
# To show debugging messages, set to at least level 4.
# To show informational messages, set to at least level 3.
# To show warning messages, set to at least level 2.
# To show exception messages, set to at least level 1.
# To show only critical and base messages, set to 0.
level = 2
# Set to the areas to log (console, main log, sp log, script log):
# Console = 1
# Main log = 2
# SP log = 4
# Script log = 8
# Add each of the areas up and set the value to that number.
# Example:
# To have the messages print to the console and be added to SP's log:
# Console + SP log = 1 + 4 = 5
areas = 1
I did a similar but not the same output format as needed:
I mean all logs without prefix datetime.
Syntax: Select all
gg_logger = LogManager(
'gg', _level, _areas, 'gungame',
'%(asctime)s - %(name)s\t-\t%(levelname)s\n%(message)s',
'%m-%d-%Y %H:%M:%S')
I mean all logs without prefix datetime.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 72 guests