Skip to content

how to order keys? #42

Description

@rophy

I want "timestamp" to be dispayed as the first column, but not sure how to do that.

I tried this:

class LogFormatter(Logfmter):
    def format(self, record):
        record.ts = datetime.now().astimezone().isoformat()
        return super().format(record)

logger = logging.getLogger('neo4j-client')
handler = logging.StreamHandler()
formatter = LogFormatter(
    keys=["ts", "at"],
    mapping={"ts": "ts", "at": "levelname"}
)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)

And hoped the keys arg could determine orders, but no luck:

at=INFO msg=Success total=9 success=6 errors=3 ts=2025-09-07T13:09:44.070825+00:00
at=INFO msg=Success total=10 success=7 errors=3 ts=2025-09-07T13:09:45.076040+00:00
at=INFO msg=Success total=11 success=8 errors=3 ts=2025-09-07T13:09:46.080163+00:00
at=INFO msg=Success total=12 success=9 errors=3 ts=2025-09-07T13:09:47.084549+00:00
at=INFO msg=Success total=13 success=10 errors=3 ts=2025-09-07T13:09:48.088060+00:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions