Skip to content

Example of Python logging with formats and file handlers across various modules and packages.

License

Notifications You must be signed in to change notification settings

LHHegland/python_logging

Repository files navigation

Python Logging Example

NAMESPACE: me.hegland-lance.examples.python.logging

PURPOSE: Example of Python logging with formats and file handlers across various modules and packages.

.

Table of Contents

.

Features

Example of Python logging, including the following:

  • single reusable and easily importable module for logging
  • quick and easy to scan logging output
    • contextual color symbols for log scanning
    • different message formatting based on messaging level: FYI (e.g. debug, info) vs alert (e.g. warning, error, critical, exception)
  • vital information for experimenting and debugging
    • system environmental variables logged when execution initiated
    • logger names indicate modules submitting messages
    • alert messages include stack trace
    • log file naming includes module and timestamp
  • flexible
    • options to output to file or stderr
  • examples to build from
    • sample log messages
    • logging library use with loggers, handlers, formatters, and filters.
    • argparse for command line interface help messaging

.

Background

Lance created to help him learn how to incorporate Python logging across multiple modules plus quickly find vital information for experimenting and debugging.

.

Known Issues

None

.

Requirements

  1. Familiarity and access to Python development tools, such as recent versions of the following:
    Tool Download Reference with VSCode
    Python Link Link Link
    Git Link Link Link
    GitHub Link Link

.

Installation

  1. Review README.
  2. Satisfy minimum requirements.
  3. Get the repository.
    1. Create a local working directory (e.g. D:\abc\...\xyz\python-logging\)
    2. From your local working directory python-logging, clone remote GitHub repository LHHegland/python_logging.git (git clone git@github.com:LHHegland/python_logging.git)

.

Configuration

None

.

Usage

  1. Review README.md.
  2. Complete installation.
  3. Review sample log and code in modules, especially utils\logz.py, test.py, and a few pkg_x\mdl_x.py.
  4. Experiment with utils\logs.py
    1. Execute py test.py
    2. Review logs\test-[timestamp].log
  5. Experiment with utils\logz.py
    1. Execute py utils\logz.py --help
    2. Review on-screen results

.

Contributors

.

Roadmap

None

.

License

GNU General Public License v3.0 (GNU GPLv3)

About

Example of Python logging with formats and file handlers across various modules and packages.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages