Lightstreamer C++ Client SDK
Loading...
Searching...
No Matches
ConsoleLoggerProvider.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Lightstreamer Srl
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef INCLUDED_Lightstreamer_ConsoleLoggerProvider
17#define INCLUDED_Lightstreamer_ConsoleLoggerProvider
18
19#include "Lightstreamer/LoggerProvider.h"
20#include <map>
21#include <memory>
22
25#ifdef _MSC_VER
26 #if defined(HXCPP_DLL_IMPORT)
27 #define LIGHTSTREAMER_WIN_API __declspec(dllimport)
28 #elif defined (HXCPP_DLL_EXPORT)
29 #define LIGHTSTREAMER_WIN_API __declspec(dllexport)
30 #else
31 #define LIGHTSTREAMER_WIN_API
32 #endif
33 #define LIGHTSTREAMER_NIX_API
34#else
35 #if defined(HXCPP_DLL_EXPORT)
36 #define LIGHTSTREAMER_NIX_API __attribute__((visibility("default")))
37 #else
38 #define LIGHTSTREAMER_NIX_API
39 #endif
40 #define LIGHTSTREAMER_WIN_API
41#endif
42
43namespace Lightstreamer {
44
48enum class ConsoleLogLevel {
54 Trace = 0,
60 Debug = 10,
66 Info = 20,
72 Warn = 30,
78 Error = 40,
84 Fatal = 50
85};
86
92class LIGHTSTREAMER_NIX_API ConsoleLoggerProvider: public LoggerProvider {
93 ConsoleLogLevel _level;
94 std::map<std::string, std::unique_ptr<Logger>> _loggers;
95public:
101 ConsoleLoggerProvider(ConsoleLogLevel level) : _level(level) {}
102
103 LIGHTSTREAMER_WIN_API Logger* getLogger(const std::string& category) override;
104};
105
106} // namespace Lightstreamer
107
108#endif // INCLUDED_Lightstreamer_ConsoleLoggerProvider
ConsoleLogLevel
Logging level.
Definition ConsoleLoggerProvider.h:48
@ Info
Info logging level.
@ Warn
Warn logging level.
@ Fatal
Fatal logging level.
@ Error
Error logging level.
@ Debug
Debug logging level.
@ Trace
Trace logging level.
Simple concrete logging provider that logs on the system console.
Definition ConsoleLoggerProvider.h:92
ConsoleLoggerProvider(ConsoleLogLevel level)
Creates an instance of the concrete system console logger.
Definition ConsoleLoggerProvider.h:101
LIGHTSTREAMER_WIN_API Logger * getLogger(const std::string &category) override
Request for a Logger instance that will be used for logging occurring on the given category.
Interface to be implemented to consume log from the library.
Definition Logger.h:27
Simple interface to be implemented to provide custom log consumers to the library.
Definition LoggerProvider.h:29