blob: ddc4eb277b3f0738e760165e3dba846dc8f407a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (C) 2014-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
#ifndef VSOMEIP_LOGGER_IMPL_HPP
#define VSOMEIP_LOGGER_IMPL_HPP
#include <memory>
#include <string>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/trivial.hpp>
#include "logger.hpp"
#include "dlt_sink_backend.hpp"
namespace vsomeip {
class configuration;
BOOST_LOG_ATTRIBUTE_KEYWORD(channel, "Channel", std::string)
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity",
boost::log::trivial::severity_level)
typedef boost::log::sinks::synchronous_sink<
boost::log::sinks::text_ostream_backend> sink_t;
typedef boost::log::sinks::synchronous_sink<
dlt_sink_backend> dlt_sink_t;
class logger_impl: public logger {
public:
static std::shared_ptr<logger_impl> & get();
static void init(const std::shared_ptr<configuration> &_configuration);
logger_impl();
boost::log::sources::severity_logger<
boost::log::trivial::severity_level> & get_internal();
private:
void enable_console();
void enable_file(const std::string &_path);
void enable_dlt();
private:
boost::log::sources::severity_logger<
boost::log::trivial::severity_level> logger_;
boost::log::trivial::severity_level loglevel_;
boost::shared_ptr<sink_t> console_sink_;
boost::shared_ptr<sink_t> file_sink_;
boost::shared_ptr<dlt_sink_t> dlt_sink_;
private:
void use_null_logger();
};
} // namespace vsomeip
#endif // VSOMEIP_INTERNAL_LOG_OWNER_HPP
|