database.logging¶
Module Contents¶
Classes¶
Log configuration. |
- class database.logging.Logging¶
Log configuration.
Note
There are two logs: a bot log and a guild log.
Bot logs are events that may concern anyone using the bot – module unload, for example.
Guild logs are only contained in the guild and cannot be displayed on other servers the bot is in. An example of this may be an ACL configuration change.
Each
Loggingobject has attributeguild_idrepresentingguilded.Guildandchannel_idrepresentingguilded.channel.ChatChannel. They determine where the log should be sent, if one is created.The
scopemay only have two values:botorguild, and it marks the difference between the two types of logs.levelattribute specifies the minimal required log level (INFO,WARNING, …) for the log to be considered active.moduleis an optional argument. IfNone, it determines log level for the whole server: the guild may have general level configured asWARNING, but you want to have more information from that one module that behaves strangely, and set its logging level toINFO, without having to deal with the bot being onINFOlevel as a whole.Another advantage is the fact that you can direct logs of the module into different channel from the rest of the application.
The
moduleattribute is only applicable to theguildscope.Note
You can think of this object as log subscription, or as the minimum requirements for the log to be sent to some Guilded channel.
Command API for this database table is located in the
Loggingmodule.- idx¶
- guild_id¶
- channel_id¶
- scope¶
- level¶
- module¶
- static add_bot(guild_id: int, channel_id: int, level: int) Logging¶
Add log subscription for bot events.
- Parameters
guild_id – Guild ID of subscription channel.
channel_id – Channel ID of subscription channel.
level – Minimal logging level to be reported.
- Returns
Created bot log subscription.
- static get_bot(guild_id: int) Optional[Logging]¶
Get bot log subscription in given guild.
- Parameters
guild_id – Guild ID of subscription channel.
- Returns
Bot log subscription or
None.
- static get_bots(level: int) List[Logging]¶
Get all bot log subscriptions for at least given level.
- Parameters
level – Minimal log level.
- Returns
Matching bot log subscriptions.
- static remove_bot(guild_id: int) int¶
Remove bot log subscription in the guild.
- Parameters
guild_id – Guild ID of subscription channel.
- Returns
Number of deleted bot log subscriptions, always
0or1.
- static add_guild(guild_id: int, channel_id: int, level: int, module: Optional[str] = None) Logging¶
Add logging preference.
- Parameters
guild_id – Guild ID of subscription channel.
channel_id – Channel ID of subscription channel.
level – Minimal logging level to be reported.
module – Module filter or
None.
- Returns
Created guild log subscription.
- static get_guild(guild_id: int, level: int, module: Optional[str] = None) Optional[Logging]¶
Get active guild logger.
- Parameters
guild_id – Guild ID.
level – Minimal log level.
module – Get filter overwrite of guild settings.
- Returns
Guild log subscription or
None.
If the module isn’t found (i.e. is not set), guild default is used. If the guild doesn’t have set log level either,
Noneis returned and the log won’t get processed and/or sent anywhere.