Logging

Please post any questions about developing your plugin here. Please use the search function before posting!
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Logging

Postby nullable » Tue Jul 28, 2015 4:45 am

What better use for logging in the plugin?
Loggers or logging or something else?
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 29, 2015 5:40 am

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:

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
Image
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Wed Jul 29, 2015 9:00 pm

I did a similar but not the same output format as needed:

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 126 guests