core.logging

Module Contents

Classes

LogLevel

Enum where members are also (and must be) ints

LogEntry

Representation of the log event.

Logger

Logger base. Not meant to be used by itself.

Bot

Bot-wide logger.

Guild

Guild-wide logger

Functions

get_main_directory() → str

Return path to the directory containing lemon.py script.

write_log(entry) → None

Write log entry to the log file.

Attributes

main_directory

LogActor

LogSource

core.logging.get_main_directory() str

Return path to the directory containing lemon.py script.

core.logging.main_directory
class core.logging.LogLevel

Enum where members are also (and must be) ints

DEBUG = 10
INFO = 20
WARNING = 30
ERROR = 40
CRITICAL = 50
NONE = 100
core.logging.write_log(entry) None

Write log entry to the log file.

core.logging.LogActor
core.logging.LogSource
class core.logging.LogEntry(stack: List[traceback.FrameSummary], scope: str, level: LogLevel, actor: LogActor, source: LogSource, message: str, **extra: dict)

Representation of the log event.

dump(self)
format_guilded(self)

Format entry so it can be sent to guilded logging channel.

This is similar to format_guilded(), but it doesn’t contain time information.

format_stderr(self)

Format entry so it can be sent to log file.

This is similar to format_guilded(), but it also contains time information.

property function(self)

Get function name.

property lineno(self)

Get line number.

property actor_id(self)

Get actor’s guilded snowflake ID.

property actor_name(self)

Get actor’s guilded name.

property guild_id(self)

Get guild’s guilded snowflake ID.

property guild_name(self)

Get guild’s name.

property channel_id(self)

Get channel’s guilded snowflake ID.

property channel_name(self)

Get channel’s name.

property levelstr(self)

Get log level in string representation.

property levelno(self)

Get log level in numeric representation.

property filename(self)

Get filename of the source function.

property module(self)

Get module name of the source function.

class core.logging.Logger(bot: guilded.ext.commands.bot)

Logger base. Not meant to be used by itself.

bot
scope :str
abstract static logger(bot: guilded.ext.commands.bot)

Get singleton instance of Logger class.

This function has to be implemented in subclass.

async _log(self, level: LogLevel, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event on server, prepare for guilded-side logging.

async _maybe_send_bot(self, entry: LogEntry)

Send the log entry to guild’s channel, if the guild is subscribed for bot logs of level.

async _maybe_send_guild(self, entry: LogEntry)

Send the log entry to guild’s channel, if the guild is subscribed for guild logs of this level.

async _send(self, entry: LogEntry, channels: List[database.logging.Logging])

Distribute the log entry to all subscribed guilded channels.

async debug(self, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event with DEBUG level.

async info(self, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event with INFO level.

async warning(self, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event with WARNING level.

async error(self, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event with ERROR level.

async critical(self, actor: LogActor, source: LogSource, message: str, **extra: dict)

Log event with CRITICAL level.

class core.logging.Bot(bot=None)

Bot-wide logger.

This class subclasses the Logger class. By using the “bot” scope, it makes it possible to use two log classes (along with “guild” scope) with identical API. Because the logs can be async-sent to the guilded logging channel, they have to operate in await-async style.

__instance
bot
scope :str = bot
static logger(bot=None)

Get singleton instance of Bot logger.

class core.logging.Guild(bot=None)

Guild-wide logger

This class subclasses the Logger class. By using the “guild” scope, it makes it possible to use two log classes (along with “bot” scope) with identical API. Because the logs can be async-sent to the guilded logging channel, they have to operate in await-async style.

__instance
bot
scope :str = guild
static logger(bot=None)

Get singleton instance of Guild logger.