1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/syslog_bsd.md

87 lines
2.1 KiB
Markdown
Raw Normal View History

2022-08-12 10:16:15 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.syslog_bsd"></a>
# jc.parsers.syslog\_bsd
jc - JSON Convert Syslog RFC 3164 string parser
This parser accepts a single syslog line string or multiple syslog lines
separated by newlines. A warning message to `STDERR` will be printed if an
2022-08-16 10:01:27 -07:00
unparsable line is found unless `--quiet` or `quiet=True` is used.
2022-08-12 10:16:15 -07:00
Usage (cli):
$ echo '<34>Oct 11 22:14:15 mymachine su: su root...' | jc --syslog-bsd
2022-08-12 10:16:15 -07:00
Usage (module):
import jc
result = jc.parse('syslog_bsd', syslog_command_output)
Schema:
[
{
"priority": integer/null,
"date": string,
"hostname": string,
2022-08-16 10:01:27 -07:00
"tag": string/null,
"content": string,
"unparsable": string, # [0]
2022-08-12 10:16:15 -07:00
}
]
[0] this field exists if the syslog line is not parsable. The value
is the original syslog line.
2022-08-12 10:16:15 -07:00
Examples:
$ cat syslog.txt | jc --syslog-bsd -p
[
{
"priority": 34,
"date": "Oct 11 22:14:15",
"hostname": "mymachine",
"tag": "su",
"content": "'su root' failed for lonvick on /dev/pts/8"
}
]
2022-08-12 10:16:15 -07:00
$ cat syslog.txt | jc --syslog-bsd -p -r
[
{
"priority": "34",
"date": "Oct 11 22:14:15",
"hostname": "mymachine",
"tag": "su",
"content": "'su root' failed for lonvick on /dev/pts/8"
}
]
2022-08-12 10:16:15 -07:00
<a id="jc.parsers.syslog_bsd.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/syslog_bsd.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/syslog_bsd.py)
2022-08-12 10:16:15 -07:00
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)