Skip to main content

A Python library to setup clean structured logs, for local development, and production with Google Cloud Logging.

Project description

Octopulse Python Logger Package

This is a Python library to setup clean structured logs, for local development, and production with Google Cloud Logging.

This logger uses these external packages:

  • google-cloud-logging
  • structlog
  • colorama
  • python-json-logger

Installation

Use the package manager pip to install the package.

pip install octopulse-logger

Setup

To be able to sent logs to GCP, you need to provide authentication credentials to your application code by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS.
Replace [PATH] with the file path of the JSON file that contains your service account key.

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

Usage

You have the possibility to add global arguments that will add contextual information to all logs.

from octopulse_logger import logger_setup

# setup the logger
logger_setup.setup('logger_name', setup_google_logging=True, setup_stdout_logging=True, logger_level='DEBUG', my_global_var="foobar")

Setup setup_google_logging and/or setup_stdout_logging to send logs to Google Cloud Logging and/or std output.

Then you can start to log with default logger or structlog :

import logging
import structlog

structlog_logger = structlog.getLogger('logger_name')
structlog_logger.warning('Warning !', value_a=1)
# or
basic_logger = logging.getLogger('logger_name')
basic_logger.error('An error occurred :(')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

octopulse-logger-0.2.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

octopulse_logger-0.2.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file octopulse-logger-0.2.1.tar.gz.

File metadata

  • Download URL: octopulse-logger-0.2.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for octopulse-logger-0.2.1.tar.gz
Algorithm Hash digest
SHA256 60f29fa1e428c169ec4230bb50b79b1ef0947694ad845fd6420f3067cf1947fe
MD5 2fc289da682adf119e5bd23a24c56dc6
BLAKE2b-256 0e071756b44b177f7b9562c46ccd37d51cb64cd5b4a54365fcf389a02b0da238

See more details on using hashes here.

File details

Details for the file octopulse_logger-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: octopulse_logger-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for octopulse_logger-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b5d348f469e01e675fb7ba27c605c02b369d14a8cdb52121269d9dd378cf88b
MD5 431629c50510c0ad3bbb1d111d2d3f30
BLAKE2b-256 c7be45c656907f7dbbf5ff5843eeaf24ffb9269c6db5924bfd4cfde843911765

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