Skip to content

scoped/better structured logs #519

@bobheadxi

Description

@bobheadxi

Example scenario: I'm looking at #510 and want to look at all logs associated with all user edit and team refresh commands. Seems rather nontrivial to do without knowing a list of all the function names involved at the moment, since our current logs just have the context:

{utils.get_team_by_name():33 /app/db/utils.py}

This does not tell me very much about who called the function, or which request this event happened in, and so on.

I do this in other projects by parameterizing and propagating loggers. For example:

func A():
   log = logger.new("field0", "A")
   B(logger.new("field1", "B"))

func B(log):
   C(log.new("field2", "C"))

func C(log):
   log.print("hello world")  # time=X, hello world, field0=A, field1=B, field2=C

This makes it much easier to scope down categories of events (starting at A, A including B, all 3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme:refactoringSomething needs to be cleaned up or refactored

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions