Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2020 YADRO |
Artem Senichev | efd5d74 | 2018-10-24 16:14:04 +0300 | [diff] [blame] | 3 | |
| 4 | #pragma once |
| 5 | |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 6 | #include <cstddef> |
| 7 | |
Nan Zhou | 042b5ba | 2021-06-18 09:32:45 -0700 | [diff] [blame] | 8 | enum class Mode |
| 9 | { |
| 10 | bufferMode, |
| 11 | streamMode |
| 12 | }; |
| 13 | |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 14 | /** |
| 15 | * @struct Config |
| 16 | * @brief Configuration of the service, initialized with default values. |
Artem Senichev | efd5d74 | 2018-10-24 16:14:04 +0300 | [diff] [blame] | 17 | */ |
| 18 | struct Config |
| 19 | { |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 20 | /** |
| 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 Senichev | efd5d74 | 2018-10-24 16:14:04 +0300 | [diff] [blame] | 26 | |
Nan Zhou | 042b5ba | 2021-06-18 09:32:45 -0700 | [diff] [blame] | 27 | /** The following configs are for both modes. */ |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 28 | /** @brief Socket ID used for connection with host console. */ |
| 29 | const char* socketId = ""; |
Nan Zhou | 042b5ba | 2021-06-18 09:32:45 -0700 | [diff] [blame] | 30 | /** @brief The mode the service is in. */ |
| 31 | Mode mode = Mode::bufferMode; |
| 32 | |
| 33 | /** The following configs are for buffer mode. */ |
Artem Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 34 | /** @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 Zhou | 042b5ba | 2021-06-18 09:32:45 -0700 | [diff] [blame] | 46 | |
| 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 Senichev | e8837d5 | 2020-06-07 11:59:04 +0300 | [diff] [blame] | 50 | }; |