blob: 1a213b46ec19bc762dd09199c1cfc67079db417c [file] [log] [blame]
Artem Senicheve8837d52020-06-07 11:59:04 +03001// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2020 YADRO
Artem Senichevefd5d742018-10-24 16:14:04 +03003
4#pragma once
5
Artem Senicheve8837d52020-06-07 11:59:04 +03006#include <cstddef>
7
Nan Zhou042b5ba2021-06-18 09:32:45 -07008enum class Mode
9{
10 bufferMode,
11 streamMode
12};
13
Artem Senicheve8837d52020-06-07 11:59:04 +030014/**
15 * @struct Config
16 * @brief Configuration of the service, initialized with default values.
Artem Senichevefd5d742018-10-24 16:14:04 +030017 */
18struct Config
19{
Artem Senicheve8837d52020-06-07 11:59:04 +030020 /**
21 * @brief Constructor: load configuration from environment variables.
22 *
23 * @throw std::invalid_argument invalid format in one of the variables
24 */
25 Config();
Artem Senichevefd5d742018-10-24 16:14:04 +030026
Nan Zhou042b5ba2021-06-18 09:32:45 -070027 /** The following configs are for both modes. */
Artem Senicheve8837d52020-06-07 11:59:04 +030028 /** @brief Socket ID used for connection with host console. */
29 const char* socketId = "";
Nan Zhou042b5ba2021-06-18 09:32:45 -070030 /** @brief The mode the service is in. */
31 Mode mode = Mode::bufferMode;
32
33 /** The following configs are for buffer mode. */
Artem Senicheve8837d52020-06-07 11:59:04 +030034 /** @brief Max number of messages stored inside intermediate buffer. */
35 size_t bufMaxSize = 3000;
36 /** @brief Max age of messages (in minutes) inside intermediate buffer. */
37 size_t bufMaxTime = 0;
38 /** @brief Flag indicated we need to flush console buffer as it fills. */
39 bool bufFlushFull = false;
40 /** @brief Path to D-Bus object that provides host's state information. */
41 const char* hostState = "/xyz/openbmc_project/state/host0";
42 /** @brief Absolute path to the output directory for log files. */
43 const char* outDir = "/var/lib/obmc/hostlogs";
44 /** @brief Max number of log files in the output directory. */
45 size_t maxFiles = 10;
Nan Zhou042b5ba2021-06-18 09:32:45 -070046
47 /** The following configs are for stream mode. */
48 /** @brief Path to the unix socket that receives the log stream. */
49 const char* streamDestination = "/run/rsyslog/console_input";
Artem Senicheve8837d52020-06-07 11:59:04 +030050};