Skip to main content

Extension to Python `logging` functionality.

Project description


This Python project is an extension of the native Python component logging providing more robust message formatting for standard and JSON logging output, and in addtion allowing for extra content populated as dictionaries.

Work In Progress

The following still needs to be performed for this Python project:

  • Unit-testing: This project will be switching over to using Python native Unit testing framework unittest.
  • More concise documentation is required.
  • Travis CI
  • Badges



pip install pyfortified_logging


Function: get_logger()

def get_logger(

get_logger(): Parameters

Parameter Purpose
logger_name Return a logger with the specified name or, if name is None, return a logger which is the root logger of the hierarchy.
logger_format LoggingFormat
logger_output LoggingOutput
logger_handler logging.StreamHandler() or logging.FileHandler()

Logging Levels

Same Python logging levels, including one additional level NOTE.

Level Purpose
DEBUG Detailed information, typically of interest only when diagnosing problems.
NOTE Detailed information, request processing, for example, request using cURL.
INFO Confirmation that things are working as expected. [DEFAULT]
WARNING An indication that something unexpected happened, or indicative of some problem in the near future. The software is still working as expected.
ERROR Due to a more serious problem, the software has not been able to perform some function.
CRITICAL A serious error, indicating that the program itself may be unable to continue running.

Logging Format

Format Purpose
STANDARD Standard logging format.
JSON JSON logging format. [DEFAULT]
class LoggingFormat(object):
    """TUNE Logging Format ENUM
    STANDARD = "standard"
    JSON = "json"

Logging Output

Output Purpose
STDOUT Standard Output to terminal
STDOUT_COLOR Standard Output using colored terminal
FILE Standard Output to file created within ./tmp/log_<epoch time seconds>.json.
class LoggingOutput(object):
    """Logging Format ENUM
    STDOUT = "stdout"
    STDOUT_COLOR = "color"
    FILE = "file"

Logging JSON Format

import logging
from pyfortified_logging import (LoggingFormat, get_logger, __version__)

log = get_logger(
)"logging: info", extra={'test': __name__})
log.note("logging: note", extra={'test': __name__})
log.debug("logging: debug", extra={'test': __name__})
log.warning("logging: warning", extra={'test': __name__})
log.error("logging: error", extra={'test': __name__})
log.critical("logging: critical", extra={'test': __name__})
log.exception("logging: exception", extra={'test': __name__})

Logging JSON Example Output

$ python3 examples/

{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "INFO", "name": "__main__",
"version": "0.1.6", "message": "logging: info", "test": "__main__"}
{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "NOTE", "name": "__main__",
"version": "0.1.6", "message": "logging: note", "test": "__main__"}
{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "WARNING", "name": "__main__",
"version": "0.1.6", "message": "logging: warning", "test": "__main__"}
{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "ERROR", "name": "__main__",
"version": "0.1.6", "message": "logging: error", "test": "__main__"}
{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "CRITICAL", "name": "__main__",
"version": "0.1.6", "message": "logging: critical", "test": "__main__"}
{"asctime": "2018-05-11 05:41:39 -0700", "levelname": "ERROR", "name": "__main__",
"version": "0.1.6", "message": "logging: exception", "exc_info": "NoneType: None",
"test": "__main__"}


pyfortified-logging module is built upon Python 3 and has dependencies upon several Python modules available within Python Package Index PyPI.

make install-requirements


python3 -m pip uninstall --yes --no-input -r requirements.txt
python3 -m pip install --upgrade -r requirements.txt

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyfortified-logging, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size pyfortified_logging-0.2.1-py3-none-any.whl (12.5 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size pyfortified-logging-0.2.1.tar.gz (31.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page