modbot.utilities.logging.Logging

class modbot.utilities.logging.Logging(run_config)[source]

Bases: object

Methods

append_log(line)

Add entry to log

build_action_log_entry(action, user, ...)

Build action log entry from message content

build_chat_log_entry(info)

Build standard chat message log entry

get_info_from_pubsub(msg_dict)

Get info from PubSub message for logging

get_value(key, dictionary)

Search nested dictionary for key

initialize_logger(run_config)

Initialize private logger

Attributes

USER_LOG

Log handling class

USER_LOG = {}

Log handling class

append_log(line)[source]

Add entry to log

Parameters

line (str) – Line to write to log after some sanitizing

static build_action_log_entry(action, user, moderator, msg, secs, msg_id)[source]

Build action log entry from message content

Parameters
  • action (str) – Moderation action. e.g ban, timeout, delete

  • user (str) – Username

  • moderator (str) – Moderator username who performed action

  • msg (str) – The message which preceeded the mod action

  • secs (str) – Timeout length in seconds

  • msg_id (str) – Message id

Returns

Log entry containing moderation action info

Return type

str

static build_chat_log_entry(info)[source]

Build standard chat message log entry

Parameters

info (dict) – Dictionary of info from IRC message

Returns

Chat log entry to write to log

Return type

str

get_info_from_pubsub(msg_dict)[source]

Get info from PubSub message for logging

Parameters

msg_dict (dict) – Dictionary containing PubSub message info

Returns

  • action (str) – Moderation action. e.g ban, timeout, delete

  • user (str) – Username

  • moderator (str) – Moderator username who performed action

  • msg (str) – The message which preceeded the mod action

  • secs (str) – Timeout length in seconds

  • msg_id (str) – Message id

static get_value(key, dictionary)[source]

Search nested dictionary for key

Parameters
  • key (str) – Key to search dictionary for

  • dictionary (dict) – Dictionary to search key for

Returns

Value in dictionary corresponding to key, or empty string if not found

Return type

str

initialize_logger(run_config)[source]

Initialize private logger

Parameters

run_config (RunConfig) – RunConfig class storing run time configuration parameters

Returns

Private logger used to write chat messages and mod actions

Return type

logger