Skip to content

Need examples of Action.warn etc.  #3

@tompaton

Description

@tompaton

I'm trying to refactor some code that uses the standard logging.getLogger to use lithoxyl and I'm a bit stuck without some more examples comparing the old style with the new.

In particular, how should I go about converting code that looks like:

logger.info('starting some process')
logger.debug('intermediate result %d', a)
logger.debug('another intermediate result %s', b)
logger.info('complete')

Logging the start/finish is fine, but I'm stuck on the "right" way to log the intermediate results. Should they just be assigned to Action's data:

with app_log.info('process') as act:
    act['intermediate result'] = a
    act.success()

That feels a bit clunky as the resulting repr of the data in the log line is pretty unreadable and out of order.

Or can warn be used? It doesn't seem quite like it does what I want as it has a different level than the Action and it's not outputting how I would expect.

with app_log.info('process') as act:
    act.warn('intermediate result %d', a)
    act.success()

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