2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of log system
22 #ifndef SECURITYMANAGER_LOG_H
23 #define SECURITYMANAGER_LOG_H
25 #include <dpl/singleton.h>
26 #include <dpl/noncopyable.h>
27 #include <dpl/log/abstract_log_provider.h>
31 namespace SecurityManager {
34 * SecurityManager log system
36 * To switch logs into old style, export
37 * DPL_USE_OLD_STYLE_LOGS before application start
43 typedef std::list<AbstractLogProvider *> AbstractLogProviderPtrList;
44 AbstractLogProviderPtrList m_providers;
46 bool m_isLoggingEnabled;
49 bool IsLoggingEnabled() const;
56 void Debug(const char *message,
59 const char *function);
64 void Info(const char *message,
67 const char *function);
72 void Warning(const char *message,
75 const char *function);
80 void Error(const char *message,
83 const char *function);
86 * Log pedantic message
88 void Pedantic(const char *message,
91 const char *function);
94 * Set default's DLOG provider Tag
96 void SetTag(const char *tag);
99 * Add abstract provider to providers list
101 * @notice Ownership is transfered to LogSystem and deleted upon exit
103 void AddProvider(AbstractLogProvider *provider);
106 * Remove abstract provider from providers list
108 void RemoveProvider(AbstractLogProvider *provider);
112 * Replacement low overhead null logging class
119 template <typename T>
120 NullStream& operator<<(const T&)
127 * Log system singleton
129 typedef Singleton<LogSystem> LogSystemSingleton;
131 } // namespace SecurityManager
138 /* avoid warnings about unused variables */
139 #define DPL_MACRO_DUMMY_LOGGING(message, function) \
141 SecurityManager::Log::NullStream ns; \
145 #define DPL_MACRO_FOR_LOGGING(message, function) \
148 if (SecurityManager::Log::LogSystemSingleton::Instance().IsLoggingEnabled()) \
150 std::ostringstream platformLog; \
151 platformLog << message; \
152 SecurityManager::Log::LogSystemSingleton::Instance().function( \
153 platformLog.str().c_str(), \
154 __FILE__, __LINE__, __FUNCTION__); \
158 /* Errors must be always logged. */
159 #define LogError(message) DPL_MACRO_FOR_LOGGING(message, Error)
161 #ifdef BUILD_TYPE_DEBUG
162 #define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug)
163 #define LogInfo(message) DPL_MACRO_FOR_LOGGING(message, Info)
164 #define LogWarning(message) DPL_MACRO_FOR_LOGGING(message, Warning)
165 #define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, Pedantic)
167 #define LogDebug(message) DPL_MACRO_DUMMY_LOGGING(message, Debug)
168 #define LogInfo(message) DPL_MACRO_DUMMY_LOGGING(message, Info)
169 #define LogWarning(message) DPL_MACRO_DUMMY_LOGGING(message, Warning)
170 #define LogPedantic(message) DPL_MACRO_DUMMY_LOGGING(message, Pedantic)
171 #endif // BUILD_TYPE_DEBUG
173 #endif // SECURITYMANAGER_LOG_H