Skip to content

Commit 89c0a0d

Browse files
committed
apps: application banner can log the built version. CU, DU and gNB applications always log the build version
1 parent 82a792e commit 89c0a0d

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

apps/cu/cu.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,18 @@ static void register_app_logs(const logger_appconfig& log_cfg,
128128
const cu_up_unit_logger_config& cu_up_loggers)
129129
{
130130
// Set log-level of app and all non-layer specific components to app level.
131-
for (const auto& id : {"CU", "ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
131+
for (const auto& id : {"ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
132132
auto& logger = srslog::fetch_basic_logger(id, false);
133133
logger.set_level(log_cfg.lib_level);
134134
logger.set_hex_dump_max_size(log_cfg.hex_max_size);
135135
}
136136

137+
auto& app_logger = srslog::fetch_basic_logger("CU", false);
138+
app_logger.set_level(srslog::basic_levels::info);
139+
app_services::application_message_banners::log_build_info(app_logger);
140+
app_logger.set_level(log_cfg.config_level);
141+
app_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
142+
137143
auto& config_logger = srslog::fetch_basic_logger("CONFIG", false);
138144
config_logger.set_level(log_cfg.config_level);
139145
config_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
@@ -237,9 +243,6 @@ int main(int argc, char** argv)
237243
// Setup size of byte buffer pool.
238244
init_byte_buffer_segment_pool(cu_cfg.buffer_pool_config.nof_segments, cu_cfg.buffer_pool_config.segment_size);
239245

240-
// Log build info
241-
cu_logger.info("Built in {} mode using {}", get_build_mode(), get_build_info());
242-
243246
// Log CPU architecture.
244247
// TODO
245248

apps/du/du.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@ static void initialize_log(const std::string& filename)
114114
static void register_app_logs(const logger_appconfig& log_cfg, const dynamic_du_unit_config& du_loggers)
115115
{
116116
// Set log-level of app and all non-layer specific components to app level.
117-
for (const auto& id : {"GNB", "ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
117+
for (const auto& id : {"ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
118118
auto& logger = srslog::fetch_basic_logger(id, false);
119119
logger.set_level(log_cfg.lib_level);
120120
logger.set_hex_dump_max_size(log_cfg.hex_max_size);
121121
}
122122

123+
auto& app_logger = srslog::fetch_basic_logger("GNB", false);
124+
app_logger.set_level(srslog::basic_levels::info);
125+
app_services::application_message_banners::log_build_info(app_logger);
126+
app_logger.set_level(log_cfg.config_level);
127+
app_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
128+
123129
auto& config_logger = srslog::fetch_basic_logger("CONFIG", false);
124130
config_logger.set_level(log_cfg.config_level);
125131
config_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
@@ -224,9 +230,6 @@ int main(int argc, char** argv)
224230
// Setup size of byte buffer pool.
225231
init_byte_buffer_segment_pool(du_cfg.buffer_pool_config.nof_segments, du_cfg.buffer_pool_config.segment_size);
226232

227-
// Log build info
228-
du_logger.info("Built in {} mode using {}", get_build_mode(), get_build_info());
229-
230233
// Log CPU architecture.
231234
cpu_architecture_info::get().print_cpu_info(du_logger);
232235

apps/gnb/gnb.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ static void register_app_logs(const logger_appconfig& log_cfg,
141141
const dynamic_du_unit_config& du_loggers)
142142
{
143143
// Set log-level of app and all non-layer specific components to app level.
144-
for (const auto& id : {"GNB", "ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
144+
for (const auto& id : {"ALL", "SCTP-GW", "IO-EPOLL", "UDP-GW", "PCAP"}) {
145145
auto& logger = srslog::fetch_basic_logger(id, false);
146146
logger.set_level(log_cfg.lib_level);
147147
logger.set_hex_dump_max_size(log_cfg.hex_max_size);
148148
}
149149

150+
auto& app_logger = srslog::fetch_basic_logger("GNB", false);
151+
app_logger.set_level(srslog::basic_levels::info);
152+
app_services::application_message_banners::log_build_info(app_logger);
153+
app_logger.set_level(log_cfg.config_level);
154+
app_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
155+
150156
auto& config_logger = srslog::fetch_basic_logger("CONFIG", false);
151157
config_logger.set_level(log_cfg.config_level);
152158
config_logger.set_hex_dump_max_size(log_cfg.hex_max_size);
@@ -280,9 +286,6 @@ int main(int argc, char** argv)
280286
// Setup size of byte buffer pool.
281287
init_byte_buffer_segment_pool(gnb_cfg.buffer_pool_config.nof_segments, gnb_cfg.buffer_pool_config.segment_size);
282288

283-
// Log build info
284-
gnb_logger.info("Built in {} mode using {}", get_build_mode(), get_build_info());
285-
286289
// Log CPU architecture.
287290
cpu_architecture_info::get().print_cpu_info(gnb_logger);
288291

apps/services/application_message_banners.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class application_message_banners
3737
{
3838
fmt::print("\n--== srsRAN {} (commit {}) ==--\n\n", app_name, get_build_hash());
3939
}
40+
41+
/// Logs in the given logger application build parameters.
42+
static void log_build_info(srslog::basic_logger& logger)
43+
{
44+
// Log build info
45+
logger.info("Built in {} mode using {})", get_build_mode(), get_build_info());
46+
}
4047
};
4148

4249
} // namespace app_services

0 commit comments

Comments
 (0)