23 #ifndef CTKLOGSERVICE_H
24 #define CTKLOGSERVICE_H
116 virtual void log(
int level,
const QString& message,
const std::exception* exception = 0,
117 const char* file = 0,
const char*
function = 0,
int line = -1) = 0;
145 const std::exception* exception = 0,
146 const char* file = 0,
const char*
function = 0,
int line = -1) = 0;
160 Q_DECLARE_INTERFACE(
ctkLogService,
"org.commontk.service.log.LogService")
170 int level,
const std::exception* exc = 0,
171 const char* file = 0,
const char*
function = 0,
int line = -1);
198 #define CTK_DEBUG(logService) \
199 ((logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? \
200 ctkLogStream(logService, ctkLogService::LOG_DEBUG, 0, __FILE__, __FUNCTION__, __LINE__) : \
203 #define CTK_DEBUG_EXC(logService, exc) \
204 ((logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? \
205 ctkLogStream(logService, ctkLogService::LOG_DEBUG, exc, __FILE__, __FUNCTION__, __LINE__) : \
208 #define CTK_DEBUG_SR(logService, serviceRef) \
209 ((logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? \
210 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_DEBUG, 0, __FILE__, __FUNCTION__, __LINE__)) : \
211 static_cast<ctkLogStream>(ctkNullLogStream()))
213 #define CTK_DEBUG_SR_EXC(logService, serviceRef, exc) \
214 ((logService && logService->getLogLevel() >= ctkLogService::LOG_DEBUG) ? \
215 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_DEBUG, exc, __FILE__, __FUNCTION__, __LINE__)) : \
216 static_cast<ctkLogStream>(ctkNullLogStream()))
218 #define CTK_INFO(logService) \
219 ((logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? \
220 ctkLogStream(logService, ctkLogService::LOG_INFO, 0, __FILE__, __FUNCTION__, __LINE__) : \
223 #define CTK_INFO_EXC(logService, exc) \
224 ((logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? \
225 ctkLogStream(logService, ctkLogService::LOG_INFO, exc, __FILE__, __FUNCTION__, __LINE__) : \
228 #define CTK_INFO_SR(logService, serviceRef) \
229 ((logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? \
230 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_INFO, 0, __FILE__, __FUNCTION__, __LINE__)) : \
231 static_cast<ctkLogStream>(ctkNullLogStream()))
233 #define CTK_INFO_SR_EXC(logService, serviceRef, exc) \
234 ((logService && logService->getLogLevel() >= ctkLogService::LOG_INFO) ? \
235 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_INFO, exc, __FILE__, __FUNCTION__, __LINE__)) : \
236 static_cast<ctkLogStream>(ctkNullLogStream()))
238 #define CTK_WARN(logService) \
239 ((logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? \
240 ctkLogStream(logService, ctkLogService::LOG_WARNING, 0, __FILE__, __FUNCTION__, __LINE__) : \
243 #define CTK_WARN_EXC(logService, exc) \
244 ((logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? \
245 ctkLogStream(logService, ctkLogService::LOG_WARNING, exc, __FILE__, __FUNCTION__, __LINE__) : \
248 #define CTK_WARN_SR(logService, serviceRef) \
249 ((logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? \
250 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_WARNING, 0, __FILE__, __FUNCTION__, __LINE__)) : \
251 static_cast<ctkLogStream>(ctkNullLogStream()))
253 #define CTK_WARN_SR_EXC(logService, serviceRef, exc) \
254 ((logService && logService->getLogLevel() >= ctkLogService::LOG_WARNING) ? \
255 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_WARNING, exc, __FILE__, __FUNCTION__, __LINE__)) : \
256 static_cast<ctkLogStream>(ctkNullLogStream()))
258 #define CTK_ERROR(logService) \
259 ((logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? \
260 ctkLogStream(logService, ctkLogService::LOG_ERROR, 0, __FILE__, __FUNCTION__, __LINE__) : \
263 #define CTK_ERROR_EXC(logService, exc) \
264 ((logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? \
265 ctkLogStream(logService, ctkLogService::LOG_ERROR, exc, __FILE__, __FUNCTION__, __LINE__) : \
268 #define CTK_ERROR_SR(logService, serviceRef) \
269 ((logService && logService->getLogLevel() >= ctkLogService::LOG_ERRO) ? \
270 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_ERROR, 0, __FILE__, __FUNCTION__, __LINE__)) : \
271 static_cast<ctkLogStream>(ctkNullLogStream()))
273 #define CTK_ERROR_SR_EXC(logService, serviceRef, exc) \
274 ((logService && logService->getLogLevel() >= ctkLogService::LOG_ERROR) ? \
275 static_cast<ctkLogStream>(ctkLogStreamWithServiceRef(logService, serviceRef, ctkLogService::LOG_ERROR, exc, __FILE__, __FUNCTION__, __LINE__)) : \
276 static_cast<ctkLogStream>(ctkNullLogStream()))
ctkLogStreamWithServiceRef(const ctkLogStreamWithServiceRef &logStreamWithRef)
ctkLogStreamWithServiceRef(ctkLogService *logService, const ctkServiceReference &sr, int level, const std::exception *exc=0, const char *file=0, const char *function=0, int line=-1)
~ctkLogStreamWithServiceRef()
virtual int getLogLevel() const =0
static const int LOG_ERROR
virtual void log(const ctkServiceReference &sr, int level, const QString &message, const std::exception *exception=0, const char *file=0, const char *function=0, int line=-1)=0
static const int LOG_WARNING
static const int LOG_INFO
static const int LOG_DEBUG
virtual void log(int level, const QString &message, const std::exception *exception=0, const char *file=0, const char *function=0, int line=-1)=0