Skip to content

asctime in logging will never output because strftime is not an attribute of time #725

Open
@DracoTomes

Description

@DracoTomes

Expexted behaviour:

Using this formatter the log output will include a timestamp.

logging.Formatter('%(asctime)s | %(name)s | %(levelname)s - %(message)s')

Like this:
Tue Feb 17 09:42:58 2009 | MAIN | INFO - test

Actual behaviour:

Timestamp will always be None
None | MAIN | INFO - test

Cause:

The formatTime() method checks for the strftime attribute, which does not exist in the Micropython implementation:

def formatTime(self, datefmt, record):
        if hasattr(time, "strftime"):
            return time.strftime(datefmt, time.localtime(record.ct))
        return None

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