Skip to main content

Simple Logging

  • version number: 0.0.4

  • date: 2023.03.08

  • author: Andrew J. Todd esq.

Overview

A python module to allow you to log with minimal fuss. It’s a wrapper around the standard logging module with sensible defaults and as little configuration as possible. Documentation is on [halfcooked.com](https://halfcooked.com/code/simple_log/)

Installation

To install use pip:

$ pip install simple_log

Or clone the repo:

$ hg clone https://hg.sr.ht/~andy47/simple_log
$ python setup.py install

Usage

We try and stay true to the name and make using this module as simple as possible. For the simplest case just use

>>> from simple_log import get_log
>>> my_log = get_log()
>>> my_log.info("This is an information message")
2016.11.10 22:21:51 default INFO:: This is an information message

If you want to have multiple logs just pass a name to get_log

>>> first_log = get_log("first")
>>> first_log.info("Information message to first log")
2016.11.10 22:27:30 first INFO:: Information message to first log
>>> second_log = get_log("two")
>>> second_log.debug("This is a debug message")
2016.11.10 22:28:02 two DEBUG:: This is a debug message

By default the logging level is set to ‘INFO’ (the standard module defaults to ‘WARNING’). See the [logging tutorial](https://docs.python.org/3/howto/logging.html#logging-basic-tutorial) for information on logging levels. If you would like to change the logging level, for instance to display ‘DEBUG’ messages use the setLevel method on your log object

>>> from simple_log import get_log
>>> my_log = get_log('test_log')
>>> my_log.debug('This is the first debug message')
...
>>> my_log.setLevel('DEBUG')
>>> my_log.debug('This is the second debug message')
2016.11.10 22:34:55 test_log DEBUG:: This is the second debug message

The log level values that you can pass to setLevel are ‘DEBUG’, ‘INFO’ (the default), ‘WARNING’, ‘ERROR’ or ‘CRITICAL’.

If you would like your log messages written to a file as well as the screen use the add_file function

>>> from simple_log import get_log, add_file
>>> my_log = get_log('test_log')
>>> my_log.info('This is an information message')
2016.11.12 22:48:10 test_log INFO:: This is an information message
>>> add_file('test_log', 'test_log.log')
>>> my_log.info('This is another information message')
2016.11.12 22:49:30 test_log INFO:: This is another information message
>>> cat test_log.log
2016.11.12 22:49:30 test_log INFO:: This is another information message

Contributing

If you would like to contribute please visit the project web site at - https://hg.sr.ht/~andy47/simple_log

Metadata

Release files for simple-log 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-log 0.0.4
File Size Uploaded
simple_log-0.0.4.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simple-log 0.0.4
File Interpreter ABI Platform
simple_log-0.0.4-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.9 kB

Release files / simple_log-0.0.4.tar.gz

Download URL simple_log-0.0.4.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
afca79ea17051cd3927da5daf26ea92b64a33749b49d6aab8c600bdcf9d6321e
BLAKE2b-256 checksum
How to use checksums
f9096d9db6048ced804d45ae0d3e67c3b198e3ae18c666039810489ece35ba15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / simple_log-0.0.4-py2.py3-none-any.whl

Download URL simple_log-0.0.4-py2.py3-none-any.whl
Size 4.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
33f19496c9daa908a64c5f95d81dd5b82404fc41aae697ebaab593e4685ed5c4
BLAKE2b-256 checksum
How to use checksums
0de5638f6af8da363e1148b2939fe76ede15ee99f695fba9f65a5ebbb1517bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page