Skip to content

Instantly share code, notes, and snippets.

@socheatsok78
Last active December 10, 2023 19:56
Show Gist options
  • Save socheatsok78/80d1d179c5706f85b281a5558217a5fe to your computer and use it in GitHub Desktop.
Save socheatsok78/80d1d179c5706f85b281a5558217a5fe to your computer and use it in GitHub Desktop.
lnav — Laravel Log Formatter

Laravel Log Formatter for Lnav


Installation

lnav -i https://gist.github.com/80d1d179c5706f85b281a5558217a5fe.git
# or
lnav -i git@gist.github.com:80d1d179c5706f85b281a5558217a5fe.git

Usage

lnav storage/log/laravel.log

Required

Why Lnav?

{
"laravel_log": {
"title": "Laravel Log",
"description": "Laravel Log Format",
"url": "https://gist.github.com/peakhmr/80d1d179c5706f85b281a5558217a5fe",
"regex": {
"basic": {
"pattern": "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\] (?<env>local|production)\\.(?<level>\\w+): (?<body>.+)\\n?(?:(?:Stack trace:\\n)(?<stacktrace>(?:#(?:\\d+) (?:(?:\\/\\w+\\/.+.php\\(\\d+\\)|.+):) (?:.*)\\n)*))?"
}
},
"level-field": "level",
"level": {
"info": "INFO",
"error": "ERROR",
"warning": "WARNING",
"debug": "DEBUG",
"debug2": "ALERT",
"fatal": "EMERGENCY",
"critical": "CRITICAL",
"stats": "NOTICE"
},
"value": {
"date": {
"kind": "string",
"identifier": true
},
"timezone": {
"kind": "string",
"identifier": true
},
"env": {
"kind": "string",
"identifier": true,
"description": "Laravel environment"
},
"exception": {
"kind": "string",
"identifier": true,
"description": "Laravel exception"
},
"constant": {
"kind": "string",
"identifier": true,
"description": "Laravel exception type"
},
"message": {
"kind": "string",
"identifier": false,
"description": "Laravel log"
},
"stacktrace": {
"kind": "string",
"identifier": false,
"description": "Laravel stack trace"
}
},
"sample": [
{
"line": "[2019-01-28 16:05:13] local.DEBUG: message"
},
{
"line": "[2019-01-28 16:05:13] local.INFO: message"
},
{
"line": "[2019-01-28 16:05:13] local.ALERT: message"
},
{
"line": "[2019-01-28 16:05:13] local.CRITICAL: message"
},
{
"line": "[2019-01-28 16:05:13] local.EMERGENCY: message"
},
{
"line": "[2019-01-28 16:05:13] local.NOTICE: message"
},
{
"line": "[2019-01-28 16:05:13] local.ERROR: message"
},
{
"line": "[2019-01-28 16:05:13] local.WARNING: message"
},
{
"line": "[2019-01-28 16:06:55] local.ERROR: ErrorException: Use of undefined constant Log - assumed 'Log' (this will throw an Error in a future version of PHP) in storage/framework/views/f655e371f2c47792b7525912a6908a4bfc0eafe4.php:58"
}
]
}
}
@n0099
Copy link

n0099 commented Feb 9, 2019

how about create a repo for this

@socheatsok78
Copy link
Author

I think this is too small for a repo.

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