Skip to content

Commit 408e9cb

Browse files
committed
[format] tweaks to postgres
1 parent 1b27201 commit 408e9cb

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/formats/postgres_log.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44
"description": "Format file generated from regex101 entry -- https://regex101.com/r/pwVch2/1",
55
"regex": {
66
"std": {
7-
"pattern": "(?<timestamp>^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} \\S+) \\[(?<pid>\\d+)\\] (?<level>DEBUG\\d|INFO|NOTICE|WARNING|ERROR|LOG|FATAL|PANIC|STATEMENT):\\s+(?<body>.*)$"
7+
"pattern": "(?<timestamp>^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(\\.\\d{3})? \\S+) \\[(?<pid>[\\d\\-]+)\\](?<host>\\s+\\[[^\\]]+\\])?(?<user>\\s+\\S+)? (?<level>DEBUG\\d?|DETAIL|CONTEXT|INFO|NOTICE|WARNING|ERROR|LOG|FATAL|PANIC|STATEMENT):\\s+(?<body>.*)$"
88
}
99
},
1010
"value": {
1111
"level": {
1212
"kind": "string"
1313
},
1414
"pid": {
15-
"kind": "string"
15+
"kind": "string",
16+
"identifier": true
17+
},
18+
"host": {
19+
"kind": "string",
20+
"identifier": true
21+
},
22+
"user": {
23+
"kind": "string",
24+
"identifier": true
1625
},
1726
"timestamp": {
1827
"kind": "string"
@@ -21,6 +30,9 @@
2130
"sample": [
2231
{
2332
"line": "2025-08-13 01:45:01.127 PDT [12347] LOG: database system was shut down at 2025-08-13 01:44:58 PDT"
33+
},
34+
{
35+
"line": "2025-06-05 17:10:04 MSK [608647-3] [local] postgres@postgres WARNING: terminating connection because of crash of another server process"
2436
}
2537
]
2638
}

src/ptimec.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
off_inout += 1;
6767

6868
#define ABR_TO_INT(a, b, c) (((a) << 24) | ((b) << 16) | ((c) << 8))
69+
#define ABR_TO_INT4(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | ((d)))
6970

7071
inline bool
7172
ptime_upto(char ch, const char* str, off_t& off_inout, ssize_t len)

src/ptimec_rt.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ ptime_Z_to_gmtoff(exttm* dst, const char* str, off_t& off_inout, ssize_t len)
6464
}
6565

6666
auto zone_start = (unsigned char*) &str[off_inout];
67-
uint32_t zone_int = ABR_TO_INT(zone_start[0] & ~0x20UL,
68-
zone_start[1] & ~0x20UL,
69-
zone_start[2] & ~0x20UL);
67+
uint32_t zone_int = ABR_TO_INT4(zone_start[0] & ~0x20UL,
68+
zone_start[1] & ~0x20UL,
69+
zone_start[2] & ~0x20UL,
70+
avail >= 4 ? zone_start[3] & ~0x20UL : 0);
7071
switch (zone_int) {
7172
case ABR_TO_INT('U', 'T', 'C'):
7273
PTIME_CONSUME(3, { dst->et_flags |= ETF_ZONE_SET | ETF_Z_IS_UTC; });
@@ -89,9 +90,15 @@ ptime_Z_to_gmtoff(exttm* dst, const char* str, off_t& off_inout, ssize_t len)
8990
dst->et_gmtoff = 1 * 60 * 60;
9091
break;
9192
case ABR_TO_INT('C', 'A', 'T'):
93+
case ABR_TO_INT4('C', 'E', 'D', 'T'):
94+
case ABR_TO_INT4('C', 'E', 'S', 'T'):
9295
PTIME_CONSUME(3, { dst->et_flags |= ETF_ZONE_SET; });
9396
dst->et_gmtoff = 2 * 60 * 60;
9497
break;
98+
case ABR_TO_INT('M', 'S', 'K'):
99+
PTIME_CONSUME(3, { dst->et_flags |= ETF_ZONE_SET; });
100+
dst->et_gmtoff = 3 * 60 * 60;
101+
break;
95102
case ABR_TO_INT('I', 'S', 'T'):
96103
PTIME_CONSUME(3, { dst->et_flags |= ETF_ZONE_SET; });
97104
dst->et_gmtoff = 5 * 60 * 60 + 30 * 60;

0 commit comments

Comments
 (0)