Skip to content

Commit

Permalink
src - Add text format
Browse files Browse the repository at this point in the history
  • Loading branch information
phibos committed Dec 9, 2024
1 parent 4eef54e commit 00651ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/config/output/format.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Output Format

## Text

::: routeros_log_exporter.output.format.format_text
options:
show_root_toc_entry: false

## JSON

::: routeros_log_exporter.output.format.format_json
Expand Down
23 changes: 23 additions & 0 deletions routeros_log_exporter/output/format/format_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: PhiBo DinoTools (2024)
# SPDX-License-Identifier: GPL-3.0-or-later
"""
This format plugin renders the plan log message as string. Every message is one line.
```yaml
outputs:
log_file:
type: file
# Format of the log messages
format: text
```
"""

from . import Format


class TextFormat(Format):
def process(self, data):
return f"{data.get('message_time')} {','.join(data.get('message_topics', []))} {data.get('message')}\n"


Format.register("text", TextFormat)

0 comments on commit 00651ec

Please sign in to comment.