1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // This header file defines wire format to transfer logs to listening service.
6 
7 #ifndef LIB_SYSLOG_WIRE_FORMAT_H_
8 #define LIB_SYSLOG_WIRE_FORMAT_H_
9 
10 #include <lib/syslog/logger.h>
11 #include <zircon/types.h>
12 
13 // Defines max length for storing log_metadata, tags and msgbuffer.
14 // TODO(anmittal): Increase it when zircon sockets are able to support a higher
15 // buffer.
16 #define FX_LOG_MAX_DATAGRAM_LEN (2032)
17 
18 typedef struct fx_log_metadata {
19     zx_koid_t pid;
20     zx_koid_t tid;
21     zx_time_t time;
22     fx_log_severity_t severity;
23 
24     // Increment this field whenever there is a socket write error and client
25     // drops the log and send it with next log msg.
26     uint32_t dropped_logs;
27 } fx_log_metadata_t;
28 
29 // Packet to transfer over socket.
30 typedef struct fx_log_packet {
31     fx_log_metadata_t metadata;
32 
33     // Contains concatenated tags and message and a null terminating character at
34     // the end.
35     char data[FX_LOG_MAX_DATAGRAM_LEN - sizeof(fx_log_metadata_t)];
36 } fx_log_packet_t;
37 
38 #endif // LIB_SYSLOG_WIRE_FORMAT_H_
39