Skip to content

logging.basicConfig(force=False) on empty handler list never initializes Formatter and Handler #979

Open
@nielsson4711

Description

@nielsson4711

Aiming to add minimalistic logging capabilities soon within starting phase of a micropythion program, one would call:

#minimalistic
logging.basicConfig(stream=stream.sys level=logging.DEBUG)
logger = logging.getLogger('thelog')

Aiming to get a fancy timestamp and information ordering, the call could look like:

# explicit formatting
log_fmt_mipy = "%(name)s - %(levelname)s - %(message)s"
log_fmt_dat_mipy = "%(asctime)s.%(msecs)03d"
logging.basicConfig(stream=stream.sys level=logging.DEBUG)
logger = logging.getLogger('thelog')

The Object "logger" as Logger instance on either case will NEVER get a working Handler and Formatter upon initialization. This is because logging.basicConfig() in (current) line 235 evaluates the list object Logger.handlers instead of the integer number Logger.hasHandlers().

NOTE: Initialization of a date format of type "asctime" within micropython, as shown in the code above, is not (yet) supported (by design) and thus requires explicit implementation efforts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions