Skip to content

Instantly share code, notes, and snippets.

@benje
Created October 23, 2017 22:07
Show Gist options
  • Save benje/e2ab750b0a81d11920d83af637d289f7 to your computer and use it in GitHub Desktop.
Save benje/e2ab750b0a81d11920d83af637d289f7 to your computer and use it in GitHub Desktop.
Python logging format for Lnav - http://lnav.org/
{
"pythonlogger": {
"title": "Python logger format",
"description": "Log format used by python logger class",
"url": "",
"regex": {
"main" : {
"pattern": "^\\[(?<timestamp>\\d{2}\\\/\\d{2}\\\/\\d{4} \\d{2}:\\d{2}:\\d{2})\\] (?<level>\\w+) (?<module>\\w+) (?<body>.*)$"
}
},
"timestamp-format": ["%d/%m/%Y %H:%M:%S"],
"level-field": "level",
"level": {
"critical": "CRITICAL",
"error": "ERROR",
"warning": "WARNING",
"info": "INFO",
"debug": "DEBUG"
},
"value": {
"level": { "kind" : "string", "identifier" : true },
"module": { "kind" : "string", "identifier" : true },
"body": { "kind" : "string" }
},
"sample": [
{
"line": "[12/01/2017 17:32:02] INFO views Error creating file"
}
]
}
}
@benje
Copy link
Author

benje commented Oct 23, 2017

To install:

Download this file and copy it to ~/.lnav/formats/lnav_format_python.json.

Run the following lnav command to install the format permanently:
lnav -i ~/.lnav/formats/lnav_format_python.json

http://lnav.readthedocs.io/en/latest/formats.html#installing-formats

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