Skip to main content

A log package that works with MongoDB.

Project description

The idea behind this package is possibility to you use some client or something like the Metabase for collect and analyse logs of your application.
Its return mongodb_id or None on exception case.

Its need two environments variables:

  • MONGO_DB
  • MONGO_URL

Its works with three collections:

  • error
  • info
  • critical

Arguments:

  • msg - Required
    • The message to log;
  • payload - Default is None
    • If need to log a payload that make a some request;
  • result - Default is None
    • If need to log a request result;
  • log_console - boolean default is True
    • Enable or disable log console view;
  • log_detail - boolean default is True
    • If disabled show only mongo_id and message.

Sample:

from mongo_system_log import *
log = LogThis(get_module_name())
log.info(msg="info message", payload="payload", result="result", log_console=False, log_detail=False)
log.error(msg="error message", payload="payload", result="result")
log.critical(msg="critical message", payload="payload", result="result")
log.custom(payload={"key": "value"}, collection='collection', msg_console="message on console")

get_module_name()

  • This function gets module and file name that called it. Must be called on instantiate the LogThis class.
    The arguments payload and result has default value None.

The document fields are:

  • Ip
  • HostName
  • App - File name that was executed;
  • ModuleCalled - Module name that methods where called;
  • Date - Date Time on format 2010-12-12 11:41:42,612;
  • Severity - INFO, ERROR or CRITICAL;
  • Message - The message that want to be logged;
  • Payload - A dict that used to call a request for example;
  • Result - A request result.

New method:

custom

Arguments:

  • payload - Required
    • A dict that will be sent to MongoDb;
  • collection - required
    • The collection that will receive the payload;
  • msg_console - Default is string empty
    • The message that will be displayed on the console. It will not be sent to MongoDb;
  • log_console - boolean default is True
    • Enable or disable log console view;
  • log_detail - boolean default is True
    • If disabled show only mongo_id and message.

I suggest that You use the Metabase:
https://www.metabase.com/

It is amazing to analyze logs.

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

mongo_system_log-0.1.6.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

mongo_system_log-0.1.6-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file mongo_system_log-0.1.6.tar.gz.

File metadata

  • Download URL: mongo_system_log-0.1.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.19

File hashes

Hashes for mongo_system_log-0.1.6.tar.gz
Algorithm Hash digest
SHA256 07caecbb3b0046c426f59e873afb8e7e0b09df4a2da3e18529b4b8c8c9176e02
MD5 1dc53e761e4c25576be562e133c314bc
BLAKE2b-256 eaf04c49237c3d196bf9b7812512ff0bebf84edda926d97a2ead37eb5480fcdb

See more details on using hashes here.

File details

Details for the file mongo_system_log-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for mongo_system_log-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4e26a22404e9d74109a128ef2aafdbadbc3c5c58ab238e1257a1b342432e5f99
MD5 67416637de6e82420b650b73ba23892f
BLAKE2b-256 4dbcea78212956baf570fa183b5a6f9ed3c042ad12d036f60cae71a26701143d

See more details on using hashes here.

Supported by

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