Skip to main content

Logger used by Server Monitoring Discord Bot and all extensions made by me

Project description

Server monitoring Discord Bot Logger

This is a logger used by the Server Monitoring Discord Bot and every module created for it by me.

Possible log formats:

  • [COUNTER] [LEVEL]: DATA{END}
  • [COUNTER] [FILE_NAME->METHOD_1->...->CALLER]: DATA{END}
  • [COUNTER] [METHOD_1->...->CALLER]: DATA{END}

If the caller name is shown and the caller was the body of the file, a line number will be shown instead.

Available log levels:

  • TRACE
  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • EXCEPTION
  • HEADER

Options:

Variable name Description Default value
log_file_name The name of the log file None
log_folder The path of the folder to save the log file Current Directory
clear Clears the log file every time it's initialized False
level Sets the minimum level for the logger to show INFO
log_to_console Sets to log to console too True
storage_life_extender_mode Limits the writes to the file by caching the data False
max_logfile_size Limits the size of one log file in MB -1 (No limit)
max_logfile_lifetime Limits the time a log file can live (except the currently used one) -1 (No limit)
__print Callable for consol logging stdout.write
__error Callable for consol error logging. None sets to be __print stderr.write
use_caller_name Use the caller's name in consol logging instead of the level False
use_file_names Use the file name whe using the caller name or not True
use_log_name Use the log file name to differenciate between multiple loggers on console False
level_only_valid_for_console Setting this will log the unwanted levels but will not display them in console False
log_disabled Disables logging to everywhere, and disables warning about silent logging False

Additional info

The consol logging uses colors for the different levels to be more recognizable at a glance. It also supports headers, after which it indents the logs to add some structure.

TRACE

  • #00E6E5

DEBUG

  • #E600E5

INFO

  • #0BFF00

WARNING

  • #FEFF00

ERROR | EXCEPTION

  • #FF0000

HEADER

  • #4182B7

Available methods

get_buffer()

Return sthe buffer's content in a list, if the logger is set to use buffers.

flush_buffer()

Forces a writes of the buffer to the log file.

set_level(level: LEVEL)

Sets the loggers leve to be used from this point onwards.

set_folder(folder: str)

Sets the loggers folder to be used from thi point. It also runs the basic validation on the inputed path.

log(level: LEVEL, data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a log entry with the given level.
The 'only_console' argument will remove the log from logfile, and only display the 'data' with the correct coloring.

header(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a HEADER level log entry.

trace(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a TRACE level log entry.

debug(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a DEBUG level log entry.

warning(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a WARNING level log entry.

info(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a INFO level log entry.

error(data: str, exception: Exception | None = None counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)

Creates a ERROR level log entry.

exception(exception: Exception)

Creates an EXCEPTION level log entry. This will only print the exception as a traceback.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smdb_logger-1.0.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smdb_logger-1.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file smdb_logger-1.0.0.tar.gz.

File metadata

  • Download URL: smdb_logger-1.0.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for smdb_logger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 391a5b41c8127cfe6e4ed00be4924a41b49dbc9b26e7f532b89bca67c4fd7603
MD5 4379020de8cae3de4f4f93d1e4719385
BLAKE2b-256 d008256550801b7d11eb357430049823ed2e97e9274b36fcfe1bf74dd86e7d0e

See more details on using hashes here.

File details

Details for the file smdb_logger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: smdb_logger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for smdb_logger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6bdf4b241491f380e7bbebfd83f2f3d93ef566e0d64169578639fa57ce468d
MD5 160de17014ee5235e08c152216bbb7d1
BLAKE2b-256 8bc50af142e87778ab9b79da64849a31a966287fba8b2c2aef17f0b0281b8b52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page