From 06bbfdafdef58891799c70d115c82a670488b09b Mon Sep 17 00:00:00 2001 From: Martin Koch Date: Tue, 7 Jan 2020 11:22:30 +0100 Subject: AM-Utils: Introduce new logging architecture, providing separate classes for each logging channel (DLT, file or stdout) and a channel-independent wrapper class. (first preparation step of AM for build without strong dependency to DLT library) Signed-off-by: Martin Koch --- AudioManagerUtilities/include/CAmLoggerDlt.h | 90 ++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 AudioManagerUtilities/include/CAmLoggerDlt.h (limited to 'AudioManagerUtilities/include/CAmLoggerDlt.h') diff --git a/AudioManagerUtilities/include/CAmLoggerDlt.h b/AudioManagerUtilities/include/CAmLoggerDlt.h new file mode 100755 index 0000000..5af0aad --- /dev/null +++ b/AudioManagerUtilities/include/CAmLoggerDlt.h @@ -0,0 +1,90 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2017, ADIT GmbH + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * \file CAmLoggerDlt.h + * For further information see http://www.genivi.org/. + */ + +#ifndef LOGGERDLT_H_ +#define LOGGERDLT_H_ + +#include "IAmLogger.h" +#include +#include +#include +#include +#include + +namespace am +{ + +class CAmLogContextDlt : public IAmLogContext +{ +public: + CAmLogContextDlt(const char *id); + virtual ~CAmLogContextDlt() {} + DltContext *getHandle(); + +private: + /* IAmLogContext */ + bool configure(const am_LogLevel_e loglevel) override; + void send() override; + void append(const int8_t value) override; + void append(const uint8_t value) override; + void append(const int16_t value) override; + void append(const uint16_t value) override; + void append(const int32_t value) override; + void append(const uint32_t value) override; + void append(const uint64_t value) override; + void append(const int64_t value) override; + void append(const bool value) override; + void append(const std::vector &data) override; + void append(const char *value) override; + + template + void append(T value); + + bool checkLogLevel(const am_LogLevel_e logLevel) override; + +private: + const char *mId; + DltContext mDltContext; + DltContextData mDltContextData; +}; + +class CAmLoggerDlt : public IAmLogger +{ +public: + ~CAmLoggerDlt(); + + /* IAmLogger */ + void registerApp(const char *appid, const char *description) override; + void unregisterApp() override; + IAmLogContext ®isterContext(const char *contextid, const char *description) override; + IAmLogContext ®isterContext(const char *contextid, const char *description, + const am_LogLevel_e level, const am_LogStatus_e status) override; + IAmLogContext &importContext(const char *contextid = NULL) override; + void unregisterContext(const char *contextid) override; + +private: + CAmLogContextDlt &createContext(const char *contextid); + +private: + std::map mCtxTable; +}; + +} + +#endif /* LOGGERDLT_H_ */ -- cgit v1.2.1