glog

raw JSON →
0.3.1 verified Fri May 01 auth: no python maintenance

glog is a simple Google-style logging wrapper for Python, inspired by the C++ Google logging library. Version 0.3.1 is the latest on PyPI, though the project is in maintenance mode with no active development.

pip install glog
error AttributeError: module 'glog' has no attribute 'set_level'
cause glog does not expose a set_level function; levels are set via environment variable GLOG_minloglevel or flags.
fix
Set the environment variable GLOG_minloglevel (e.g., export GLOG_minloglevel=1) or use glog's internal logging level control.
error ImportError: No module named glog
cause glog is not installed or the package name is confused with google-glog (C++).
fix
Install with 'pip install glog'. Note: this is a Python-only package, not the C++ Google logging library.
error TypeError: log() missing 1 required positional argument: 'msg'
cause Calling glog.log() incorrectly; glog.log() requires at least a message argument.
fix
Use glog.info('message'), glog.warning('message'), etc., instead of glog.log().
deprecated glog uses `glog.warn()` which is deprecated; use `glog.warning()` as per Python logging conventions.
fix Replace `glog.warn(...)` with `glog.warning(...)`.
gotcha glog outputs to stderr by default, not stdout. This can confuse users expecting console output.
fix Redirect stderr if needed, or configure logging to output elsewhere.
gotcha glog uses its own formatting and does not respect Python's standard logging configuration. Changes via `logging.basicConfig` have no effect.
fix Use glog's internal configuration or consider another library if you need standard logging integration.

Basic usage showing log levels and exception logging.

import glog

if __name__ == '__main__':
    glog.info('This is an informational message')
    glog.warn('This is a warning')
    glog.error('This is an error')
    try:
        1/0
    except ZeroDivisionError:
        glog.exception('Caught an exception')