Skip to main content

flog

Improved logging system for Python

Table of Contents

Import

import forloop_modules.flog as flog
# or
from flog_pkg.flog import FlogLogger, FlogLevel

Basic Usage

flog.debug("Debug message")
flog.minor_info("Minor info message")
flog.info("Info message")
flog.warning("Warning message")
flog.error("Error message")
flog.critical("Critical message")

Log Levels

Log levels from lowest to highest:

  • DEBUG (10) - Detailed debugging information
  • MINORINFO (15) - Minor informational messages
  • INFO (20) - General informational messages
  • WARNING (30) - Warning messages (yellow)
  • ERROR (40) - Error messages (red)
  • CRITICAL (50) - Critical error messages (red)

Runtime Log Level Configuration

Using the Logger Instance (flog_pkg)

# Set default log level (using enum)
flog.logger.set_log_level(flog.FlogLevel.DEBUG)

# Set log level using string (case-insensitive)
flog.logger.set_log_level("debug")
flog.logger.set_log_level("INFO")
flog.logger.set_log_level("Warning")

# Set log level for specific class
flog.logger.set_log_level(flog.FlogLevel.INFO, class_name="MyClass")
flog.logger.set_log_level("info", class_name="MyClass")

# Get current log level
level = flog.logger.get_log_level()
level = flog.logger.get_log_level(class_name="MyClass")

# Invalid log level raises ValueError
flog.logger.set_log_level("invalid")  # Raises ValueError with helpful message

Direct FLOG_CONFIG Manipulation (works in both versions)

# Set default log level
flog.FLOG_CONFIG["DEFAULT"] = flog.FlogLevel.DEBUG

# Set log level for specific class
flog.FLOG_CONFIG["MyClass"] = flog.FlogLevel.INFO

# Get current log level
level = flog.FLOG_CONFIG.get("DEFAULT", flog.FlogLevel.WARNING)

Using in Classes

The logger automatically detects the class name from which it's called:

class MyClass:
    def __init__(self):
        flog.info("Initializing MyClass")  # Automatically detects class name
    
    def my_method(self):
        flog.debug("Debug message from method")

Using Outside Classes

When called outside of a class, no class name is shown in the output:

flog.info("This is a standalone message")  # No class name in output

Message Categories

Filter messages by category (default: "*" = all):

# Log with a specific category
flog.info("Message", message_category="important")

# Configure which categories to display
flog.MESSAGE_CATEGORIES = ["important", "errors"]

Available Enums

FlogLevel

  • CRITICAL
  • ERROR
  • WARNING
  • INFO
  • MINORINFO
  • DEBUG
  • NOTSET

LogColor

  • OKGREEN
  • ERROR
  • WARNING
  • BOLD
  • COLOROFF

Configuration

FLOG_CONFIG

Dictionary mapping class names to log levels:

  • Default level: WARNING
  • Pre-configured classes: Wizard, Scanner, CleaningUtility, DfToListHandler

Example:

flog.FLOG_CONFIG["DEFAULT"] = flog.FlogLevel.INFO
flog.FLOG_CONFIG["MyClass"] = flog.FlogLevel.DEBUG

Developer Mode

  • When DEVELOPER_MODE=True: Colored output, timestamps, class names
  • When DEVELOPER_MODE=False: Logging is disabled

Examples

Basic Logging

flog.info("Application started")
flog.warning("Low memory detected")
flog.error("Failed to connect to database")

Runtime Configuration

# Enable debug logging
flog.logger.set_log_level(flog.FlogLevel.DEBUG)
flog.debug("This will now be visible")

Class-Specific Configuration

# Set debug level for a specific class
flog.FLOG_CONFIG["DatabaseHandler"] = flog.FlogLevel.DEBUG

Using in a Class

class DeploymentSupervisor:
    def supervise(self):
        flog.info("Starting supervision")
        flog.debug("Checking deployments...")

Help Method

You can also view this help in Python:

import forloop_modules.flog as flog
flog.help()

Download files

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

Source Distribution

flogg-1.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

flogg-1.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file flogg-1.0.1.tar.gz.

File metadata

  • Download URL: flogg-1.0.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for flogg-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cf8d2a17a713fb51c399a3eb23f259881cc1cae3c7ccb76ac0232aab966f68db
MD5 3ee1f67b6de179fad35bca8f61303537
BLAKE2b-256 4fb81fdb736c771bd49b68012e9dc3bbf4032247fd9bc209c27ac640784857c2

See more details on using hashes here.

File details

Details for the file flogg-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: flogg-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for flogg-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25aab96cd0f3932af611de7bb2665b66ea443d52c588aaba8a61c682d0e36471
MD5 f67d55ddffccb853626c8b4bf9086635
BLAKE2b-256 118a90c9bca45458b159845e6f50b2f730fa6ca716cc462278b7a91e4110c7be

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page