REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
json_logging.cpp
Go to the documentation of this file.
1// Copyright (c) 2023 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
4
5#include "../../../../include/protocol/transport.h"
6#include "protocol/jsonl_logging.h"
7
8size_t msg::StreamLogger::write(uint8_t b) {
9 // size_t write(const uint8_t *buffer, size_t size) override {
10 if (new_line) {
11 target.begin_dict();
12 target.kv("type", "log");
13 target.kv("count", line_count++);
14 target.kv("time", millis());
15 target.key("msg");
16 target.begin_str();
17 new_line = false;
18 }
19 if (b == '\r')
20 return 1; // ignore CR in CR NL line endings.
21 if (b == '\n') {
22 target.end_str();
23 target.end_dict();
24 target.output.println("");
25 target.output.flush();
26 new_line = true;
27 return 1;
28 } else {
29 return target.output.write(b);
30 }
31}
32
33void msg::StartupLog::to_pb(pb_SyslogResponse &stream) {
34 stream.is_active = is_active();
35 stream.max_size = buf.max_size;
36 stream.entries = nullptr; buf.data();
37 //TODO @chris
38}
39
40void msg::activate_serial_log() { msg::Log::get().sinks.add_Serial(); }