Skip to content

Instantly share code, notes, and snippets.

@Sigri44
Last active February 9, 2025 16:06
Show Gist options
  • Save Sigri44/b9063322eb50848ab93eee08de7ebdae to your computer and use it in GitHub Desktop.
Save Sigri44/b9063322eb50848ab93eee08de7ebdae to your computer and use it in GitHub Desktop.
Lnav format for Laravel config
{
"laravel_log": {
"title": "Laravel log format",
"description": "Log format used by Laravel)",
"url": "https://laravel.com/",
"regex": {
"laravel": {
"pattern": "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\] local\\.(?<level>.*)\\: \\[(?<supplier>.*)\\] (?<body>.*)$"
}
},
"value": {
"supplier": { "kind": "string", "identifier": true },
"body": { "kind": "string", "identifier": true }
},
"level-field": "level",
"level": {
"error": "ERROR",
"warning": "WARNING",
"info": "INFO",
"debug": "DEBUG"
},
"sample": [
{ "line" : "[2019-12-26 09:11:07] local.INFO: [supplier] New file detected (checksum: abcdefghijklmnopqrstuvwxyz)" },
{ "line" : "[2019-12-26 09:11:11] local.INFO: [supplier] Start running import (#queue: 123456, checksum: abcdefghijklmnopqrstuvwxyz)" },
{ "line" : "[2019-12-26 09:11:35] local.INFO: [supplier] Get file (main) in 1.219 sec." },
{ "line" : "[2019-12-26 09:12:00] local.DEBUG: [supplier] Import file (main, 53254 lines) in 15.46 sec." },
{ "line" : "[2019-12-26 09:12:01] local.WARNING: [supplier] [collection/getData] 0.7951" },
{ "line" : "[2019-12-26 09:12:05] local.ERROR: [supplier] Import aborted, error in file." }
]
}
}
@sbrow
Copy link

sbrow commented Jun 19, 2023

If (like me) you're having trouble with multi-line outputs (e.g. exceptions), try this:

{
    "laravel_log": {
        "title": "Laravel log format",
        "description": "Log format used by Laravel)",
        "url": "https://laravel.com/",
        "regex": {
            "laravel": {
                "pattern": "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\] local\\.(?<level>[A-Z]*)\\:\\s+(?<body>([\\S ]*\\r?\\n?(?!\\[\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\])){1,})"
            }
        },
        "value": {
            "supplier": { "kind": "string", "identifier": true },
            "body": { "kind": "string", "identifier": true }
        },
        "level-field": "level",
        "level": {
            "error": "ERROR",
            "warning": "WARNING",
            "info": "INFO",
            "debug": "DEBUG"
        },
        "sample": [
            { "line" : "[2019-12-26 09:11:07] local.INFO: [supplier] New file detected (checksum: abcdefghijklmnopqrstuvwxyz)" },
            { "line" : "[2019-12-26 09:11:11] local.INFO: [supplier] Start running import (#queue: 123456, checksum: abcdefghijklmnopqrstuvwxyz)" },
            { "line" : "[2019-12-26 09:11:35] local.INFO: [supplier] Get file (main) in 1.219 sec." },
            { "line" : "[2019-12-26 09:12:00] local.DEBUG: [supplier] Import file (main, 53254 lines) in 15.46 sec." },
            { "line" : "[2019-12-26 09:12:01] local.WARNING: [supplier] [collection/getData] 0.7951" },
            { "line" : "[2019-12-26 09:12:05] local.ERROR: [supplier] Import aborted, error in file." }
        ]
    }
}

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