Skip to content

Commit

Permalink
[formats] add rails_log
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Jun 30, 2024
1 parent c36aef4 commit c3e2147
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/formats/bunyan_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "Bunyan log",
"url": "https://github.com/trentm/node-bunyan",
"description": "Bunyan JSON logging library for node.js",
"json": true,
"file-type": "json",
"line-format": [
{
"field": "time"
Expand Down
2 changes: 1 addition & 1 deletion src/formats/cloudflare_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "Cloudflare Access Log",
"description": "Cloudflare Enterprise detailed logs of metadata",
"url": "https://developers.cloudflare.com/logs/",
"json": true,
"file-type": "json",
"hide-extra": true,
"ordered-by-time": false,
"level-field": "CacheCacheStatus",
Expand Down
1 change: 1 addition & 0 deletions src/formats/formats.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ FORMAT_FILES = \
$(srcdir)/%reldir%/page_log.json \
$(srcdir)/%reldir%/pcap_log.json \
$(srcdir)/%reldir%/procstate_log.json \
$(srcdir)/%reldir%/rails_log.json \
$(srcdir)/%reldir%/redis_log.json \
$(srcdir)/%reldir%/snaplogic_log.json \
$(srcdir)/%reldir%/sssd_log.json \
Expand Down
2 changes: 1 addition & 1 deletion src/formats/lnav_debug_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Log format for lnav's own debug log",
"regex": {
"std": {
"pattern": "(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}(-|\\+)\\d{2}:\\d{2}) (?<level>\\w) (?<thread>\\w+) (?<srcfile>[^:]+):(?<srcline>\\d+) (?<body>.*)"
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}(-|\\+)\\d{2}:\\d{2}) (?<level>\\w) (?<thread>\\w+) (?<srcfile>[^:]+):(?<srcline>\\d+) (?<body>.*)"
}
},
"value": {
Expand Down
39 changes: 39 additions & 0 deletions src/formats/rails_log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
"rails_log": {
"title": "Ruby on Rails",
"description": "Format for ruby on rails",
"regex": {
"std": {
"pattern": "^(?<level_char>[A-Z]),\\s\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2}(?:T| )\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{6})?) #(?<pid>\\d+)\\]\\s+(?<level>\\w+) --\\s(?<module>[^:]+)?:\\s(?:\\[(?<reqid>\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})\\]\\s)?(?<body>.*)"
}
},
"value": {
"level": {
"kind": "string"
},
"level_char": {
"kind": "string"
},
"pid": {
"kind": "string",
"identifier": true
},
"reqid": {
"kind": "string",
"identifier": true
},
"timestamp": {
"kind": "string"
}
},
"sample": [
{
"line": "I, [2024-06-26T17:00:04.497736 #126554] INFO -- : [4eebb5e2-2f13-42f8-8644-d6c9a9e244f0] Completed 200 OK in 180ms (Views: 0.4ms | ActiveRecord: 143.3ms | Allocations: 10027)"
},
{
"line": "I, [2019-01-04 05:14:33 #123] INFO -- Main: Hello Logs!"
}
]
}
}
2 changes: 1 addition & 1 deletion src/formats/vpostgres_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"regex": {
"std": {
"pattern": "(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} \\S+) (?<session_id>[^ ]*) (?<transaction_id>[^ ]*) (?<db_name>[^ ]*) (?<user>[^ ]*) (?<remote_pair>[^ ]*) (?<pid>[^ ]+) (?<num_line>\\d+)(?<level>[^:]+):\\s+(?<body>.*)"
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} \\S+) (?<session_id>[^ ]*) (?<transaction_id>[^ ]*) (?<db_name>[^ ]*) (?<user>[^ ]*) (?<remote_pair>[^ ]*) (?<pid>[^ ]+) (?<num_line>\\d+)(?<level>[^:]+):\\s+(?<body>.*)"
}
},
"opid-field": "session_id",
Expand Down

0 comments on commit c3e2147

Please sign in to comment.