Fix undefined behaviour if std::string is constructed from NULL
[platform/core/security/device-certificate-manager-backend.git] / src / logging.h
1 /******************************************************************
2  *
3  * Copyright 2017 - 2019 Samsung Electronics All Rights Reserved.
4  *
5  * Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 #ifndef LOGGING_H_
22 #define LOGGING_H_
23
24 #include <boost/log/common.hpp>
25 #include <boost/log/expressions.hpp>
26 #include <boost/log/attributes.hpp>
27 #include <boost/log/sinks/sync_frontend.hpp>
28 #include <boost/log/sinks/syslog_backend.hpp>
29 #include <boost/log/sources/logger.hpp>
30 #include <boost/log/utility/setup/console.hpp>
31 #include <boost/log/utility/setup/common_attributes.hpp>
32 #include <boost/log/attributes/timer.hpp>
33 #include <boost/log/attributes/named_scope.hpp>
34
35 #ifdef USE_DLOG_LOGGING
36 #define LOG_TAG         "DEVICE_CERTIFICATE_MANAGER_SERVER"
37 #include <dlog.h>
38 #endif
39
40 enum class log_severity {
41         debug,
42         normal,
43         warning,
44         error
45 };
46
47 // Global logger declaration
48 BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(dcm_logger, boost::log::sources::severity_logger_mt<log_severity>)
49
50 #if defined(NDEBUG) && !defined(DEBUG)
51 #else
52 #define ENABLE_DEBUG_LOGGING            1
53 #endif
54
55 #endif /* LOGGING_H_ */