Skip to main content

For logging & accessing application data with NoSQL databases (MongoDB & ElasticSearch)

Project description

python-nosql-logger

Installation steps if using MongoDB

  pip install pymongo #"pymongo[srv]" or "pymongo[aws]"
  pip install python-nosql-logger

Initialize

For synchronous mongo logger

  from pynosql_logger.loggers import MongoLogger

  connection_string = 'your_mongodb_connection_string'
  logger = MongoLogger(connection_string)

For asynchronous mongo logger

  from pynosql_logger.async_loggers import AsyncMongoLogger

  elastic_url = 'http://127.0.0.1:9200'
  logger = AsyncMongoLogger(elastic_url)

Installation steps if using ElasticSearch

  pip install requests
  pip install python-nosql-logger

Initialize

For synchronous elastic logger

  from pynosql_logger.loggers import ElasticLogger

  elastic_url = 'http://127.0.0.1:9200'
  logger = ElasticLogger(elastic_url)

For asynchronous elastic logger

  from pynosql_logger.async_loggers import AsyncElasticLogger

  elastic_url = 'http://127.0.0.1:9200'
  logger = AsyncElasticLogger(elastic_url)

Add Log

  req_json = {
      'users': {
          'first_name': 'Hitesh',
          'last_name': 'Mishra',
          'email': 'hiteshmishra708@gmail.com'
      }
  }
  resp = logger.add_log(req_json)

Add Bulk Log

  req_json = {
      'users': [{
          'first_name': 'Test',
          'last_name': 'User 1',
          'email': 'testuser1@mailnesia.com'
      }, {
          'first_name': 'Test',
          'last_name': 'User 2',
          'email': 'testuser2@mailnesia.com'
      }]
  }
  resp = logger.add_log(req_json)

Get Log

You can pass mongo query or elastic query to get the logs

  req_json = {
      'users': {
        'first_name': 'Hitesh'
      }
  }
  resp = logger.get_log(req_json)

Get All Logs

  req_json = {
      'collection': 'users'
  }
  resp = logger.get_all_logs(req_json)

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

python_nosql_logger-1.0.5.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

python_nosql_logger-1.0.5-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file python_nosql_logger-1.0.5.tar.gz.

File metadata

  • Download URL: python_nosql_logger-1.0.5.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for python_nosql_logger-1.0.5.tar.gz
Algorithm Hash digest
SHA256 e6f0a413fe29c6f93b5a5a107de72d335e5cbd3c6bf5312b257230a6fdcdb7f7
MD5 2d6759b5ad1bad058ba7f5dbf3e41c04
BLAKE2b-256 150893e754d6a957a59e06f586ad56b56b46c4533b99ff9155094dcbe5986932

See more details on using hashes here.

File details

Details for the file python_nosql_logger-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: python_nosql_logger-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for python_nosql_logger-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2e3d40a50acb7ec811378885f1f4086b0d40a0992b9428c5b5335bb70ee4c52a
MD5 9d831c02ea01260ae6e9d554d0c4c51f
BLAKE2b-256 e7caa3ea84e1c97b3eed9a5af20469115e59527cd658200ae134dfede1be1408

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