Skip to main content

A small example package

Project description

log2mongo

It is a lightweight Package for store logs in MongoDB

Requirements

  • Python 3.12+
  • Pymongo 4.0+

Installing

pip install log2mongo

How to use it

  • Create an instance directly
#import
from log2mongo import log2mongo

#initialize
log = log2mongo('connection_string_to_mongoDB', 'ws-server-logs', level = 'DEBUG')

#use it
log.logger.debug('server starting')

containers.py

#import
from dependency_injector import containers, providers
from log2mongo import log2mongo

#initialize
logging = providers.Singleton(
   log2mongo,
   'connection_string_to_mongoDB',
   'ws-server-logs',
   level = 'DEBUG',
   )

#use it
log.logger.debug('server starting')

main.py

#import
from dependency_injector.wiring import Provide, inject
from log2mongo import log2mongo

#invoke dependency
log_service: log2mongo = Provide[Container.logging]

#use it
@inject
def main(log = log_service):
    try:
        log.logger.debug('server starting')
    except Exception as e:
        log.logger.error(e)

Constructor parameters

  • db_url: connection string to the database
  • db_name: database name
  • db_collection[optional]: collection name If this parameter is not provided, the lof level will be used as the collection name; that is, a collection called 'debug' will be created fo all messages of that level, another called 'error' for messages of that level, and so on
  • file_name[optional]: the file name where it will be invoke
  • clean_providers[optional]:All logs providers are cleared, if the value is TRUE. Default value = TRUE
  • level[optional]: log level. Default value = Error/40

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

log2mongo-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

log2mongo-0.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file log2mongo-0.1.0.tar.gz.

File metadata

  • Download URL: log2mongo-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for log2mongo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 97b63ef3be38ac09628f1a885e147ff1bbdb3df837f0add8442006440725c2fe
MD5 dd8fad0d062b0f4a2cdf3e91be5c51cb
BLAKE2b-256 21f358022c469f48d06db9b000dc408ce89ad7c6cb07afeb0def0c32e934e881

See more details on using hashes here.

File details

Details for the file log2mongo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: log2mongo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for log2mongo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f115b631688cd195f1e4f879834e74ca555f782876e3b5ff0ea4048bc5a86285
MD5 13d160c61dc3c14fdb86f80baa3605e7
BLAKE2b-256 0f2063407e4d1a74063d6f9ec5ccb28f1b2d7f84444ac5c6037cd6a43705f4f9

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