Skip to main content

A logger for python

Project description

GamuLogger

📚 Table of Contents

🔨 Installation

The package is available in the assets of the latest release on pypi.

You can install it with pip:

pip install gamuLogger

💡 Usage

  • First you need to import the package:
    from gamuLogger import deepDebug, debug, info, warning, error, critical, Logger, LEVELS, SENSITIVE_LEVELS
    

note: you can also only import the members you need instead of importing all of them.

  • Then you can use the functions like this:
    info('This is an info message')
    warning('This is a warning message')
    error('This is an error message')
    

You may note that the logging function are also available as static methods in the Logger class. This allow you to have them encapsulated in a class and use them in a more object oriented way:

from gamuLogger import Logger

Logger.info('This is an info message')
Logger.warning('This is a warning message')
Logger.error('This is an error message')

⚙️ Configuration

1. Basic Configuration

You can configure the logger using methods of the Logger class. Here is an example of how you can do it:

from gamuLogger import Logger, LEVELS, SENSITIVE_LEVELS

# default target is the standard output, name is 'stdout'

Logger.setLevel("stdout", LEVELS.INFO); # this mean yhat all logs with level less than INFO will be ignored

Logger.setSensitiveLevel("stdout", SENSITIVE_LEVELS.HIDE); # If a log message contains sensitive data, it will be hidden

Logger.addSensitiveData('myPasswordSecret'); # add 'myPasswordSecret' to the list of sensitive data (if a log message contains any of them, it will be hidden according to the sensitive level)

Logger.setModule('my-module'); # set the module name for this file to 'my-module' (this will be displayed in the log message) (by default, no module name is set)

Logger.addTarget("data.log", LEVELS.DEBUG, SENSITIVE_LEVELS.HIDE) # add a new target to the logger (this will log all messages with level less than DEBUG to the file 'data.log' and hide sensitive data if any)

Please note that the logger can be used without any manual configuration. The default configuration is:

  • target: terminal
    • level: INFO
    • sensitive mode: HIDE
  • sensitive data: []
  • module name: None

Note that the module name is set only for the current file. If you want to set the module name for all files, you need to set it in each file.

📁 Examples

you can find examples in the example directory.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

gamulogger-3.0.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

gamuLogger-3.0.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file gamulogger-3.0.2.tar.gz.

File metadata

  • Download URL: gamulogger-3.0.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gamulogger-3.0.2.tar.gz
Algorithm Hash digest
SHA256 feeca80bfda6edf8d4a07d855baa4f49b2476d833bc60facbbe660051f2aeafc
MD5 730c5e981999295d67b5764571124d54
BLAKE2b-256 c27e2a9a1dd91aca2b6382184c723d9523a88b11adde5ea769030e0650b10ae8

See more details on using hashes here.

Provenance

The following attestation bundles were made for gamulogger-3.0.2.tar.gz:

Publisher: OnRelease.yml on T0ine34/gamuLogger

Attestations:

File details

Details for the file gamuLogger-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: gamuLogger-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for gamuLogger-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94eccd96c69155744b6ec107d538120c088f9aa33696b208f997b8fc9ce852c9
MD5 c8e732ee86fd9c2abc3c74591c991f82
BLAKE2b-256 97c6adb8170159e55c8d1e85b3d93d1e236c604f71a371157cf184d28d55b176

See more details on using hashes here.

Provenance

The following attestation bundles were made for gamuLogger-3.0.2-py3-none-any.whl:

Publisher: OnRelease.yml on T0ine34/gamuLogger

Attestations:

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