Skip to main content

Ease the creation of a logger

Project description

splogging

Ever had that feeling like quickly wanting to activate logging for your script, but were slightly overwhelmed by the plethora of settings and commands, so you are now running with no logging at all?

Enter splogging!

Just run pip install, do a from ... import ... and finally initialise your logger with my_logger=logger.setup_logging().

That's all it takes to get your logging up and running.

Of course, you can customise your new logger with the parameters shown below.

Happy logging!

Install splogging

$ pip install splogging 

Use splogging

Create one logger

Use this "one logger" setup, if you want same config for output to screen (terminal) and log file.

from splogging import logger

if __name__ == "__main__":
    logger = logger.setup_logging(
        filename="my.log", when="W0", file_level="info", console_level="info",
    )

    logger.info("Log message to console and in file.")

Create multiple loggers

Use this "multiple logger" setup, if you want to configure (and use) multiple loggers separately.

Specify a unique name for each logger.

from splogging import logger

if __name__ == "__main__":
    logger_file = logger.setup_logging(
        name="A",
        filename="steven.log",
        when="W0",
        file_level="info",
        console_level=None,
    )
    logger_console = logger.setup_logging(
        name="B",
        filename="steven.log",
        when="W0",
        file_level=None,
        console_level="info",
    )

    logger_file.warning("In File!")
    logger_console.warning("In console!!!")

Parameters

  • name
    Can be left empty.
    Useful only when creating multiple, separate loggers.
  • filename
    Path and name of logfile.
  • when
    Defines when to rotate the log file.
    Check TimedRotatingFileHandler for more info.
  • backup_count
    Number of backups to keep (set to 0 to keep all rotated logs).
  • file_level
    Save log messages that have this or a higher level.
    Set to None to disable logging to file.
  • file_format
    Format of message saved to file.
    Check docs.python.org for more info.
  • file_log_datefmt
    Format of timestamp in the log message, saved to file.
    See strftime for details.
  • console_level
    Display log messages that have this or a higher level.
    Set to None to disable logging to console.
  • console_format
    Format of message, displayed in the console.
    Check Formatter Objects for more info.
  • console_log_datefmt
    Format of timestamp in the message, displayed in the console.

References

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

splogging-0.0.5.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

splogging-0.0.5-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file splogging-0.0.5.tar.gz.

File metadata

  • Download URL: splogging-0.0.5.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6

File hashes

Hashes for splogging-0.0.5.tar.gz
Algorithm Hash digest
SHA256 04be5eafe4d6f82224c9df599e9d13328dfb7cb9c2bc2338bc7e93e8cdab12f7
MD5 7418a1563115160ddcae4250eeed786c
BLAKE2b-256 a481277974f2c2a555f5e49e457948c085cd4a457c288cfffba9c4e753d9de16

See more details on using hashes here.

File details

Details for the file splogging-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: splogging-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6

File hashes

Hashes for splogging-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f8658cac638a32f8dd009ce09a0f5d160bf8d06a9aaf04fb7ccfbc9bddd6bab2
MD5 1f47a970882231d853d2a7d7f81ebe18
BLAKE2b-256 8700e9dad8077e7ab17086a639e4493151af16f83cd46805e29e8f67e9cc5772

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