Diag-Client-Lib
logger.cpp
Go to the documentation of this file.
1 /* Diagnostic Client library
2  * Copyright (C) 2024 Avijit Dey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 #include "utility/logger.h"
10 
11 namespace utility {
12 namespace logger {
13 
14 Logger::Logger(std::string_view context_id)
15  : contxt_{},
16  app_id_{},
17  context_id_{context_id},
18  registration_with_app_id_{false} {
19 #ifdef ENABLE_DLT_LOGGER
20  DLT_REGISTER_CONTEXT(contxt_, context_id_.c_str(), "Application Context");
21 #else
23 #endif
24 }
25 
26 Logger::Logger(std::string_view app_id, std::string_view context_id)
27  : contxt_{},
28  app_id_{app_id},
29  context_id_{context_id},
30  registration_with_app_id_{true} {
31 #ifdef ENABLE_DLT_LOGGER
32  DLT_REGISTER_APP(app_id_.c_str(), "Application Id");
33  DLT_REGISTER_CONTEXT(contxt_, context_id_.c_str(), "Application Context");
34 #else
36 #endif
37 }
38 
40 #ifdef ENABLE_DLT_LOGGER
41  DLT_UNREGISTER_CONTEXT(contxt_);
42  if (registration_with_app_id_) { DLT_UNREGISTER_APP(); }
43 #endif
44 }
45 
46 } // namespace logger
47 } // namespace utility
~Logger()
Destruct an instance of Logger.
Definition: logger.cpp:39
std::string app_id_
Definition: logger.h:266
Logger(std::string_view context_id)
Construct an instance of Logger.
Definition: logger.cpp:14
bool registration_with_app_id_
Definition: logger.h:272
std::string context_id_
Definition: logger.h:269
std::string contxt_
Function to send the messages to dlt infrastructure.
Definition: logger.h:263
#define UNUSED_PARAM(expr)
Definition: logger.h:21