Skip to content

Making logs to be read with VisiData #2467

Answered by cool-RR
cool-RR asked this question in Q&A
Discussion options

You must be logged in to vote

That's nice, but then if you'd look at the log of your program as tabular data, it'll be a sparse table since different log messages will use different fields. Also, because you're reinventing logging, your log won't include the logs from all the libraries you call.
I'm now experimenting with using this: 

class JsonlLogFormatter(logging.Formatter):
    def format(self, record):
        log_entry = {
            'timestamp': self.formatTime(record, self.datefmt),
            'level': record.levelname,
            'logger': record.name,
            'path': record.pathname,
            'line': record.lineno,
            'message': record.getMessage(),
        }
        return json.dumps(log_…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cool-RR
Comment options

Answer selected by cool-RR
@saulpw
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants