Imported Upstream version 1.3.99.5_20131030_SE_05e5911_SYSYNC_69de386
[platform/upstream/syncevolution.git] / src / syncevo / LogDLT.h
1 /*
2  * Copyright (C) 2012 Intel Corporation
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) version 3.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301  USA
18  */
19
20 #ifndef INCL_LOGDLT
21 #define INCL_LOGDLT
22
23 #include <config.h>
24
25 #ifdef USE_DLT
26
27 #include <syncevo/Logging.h>
28 #include <syncevo/util.h>
29
30 #include <syncevo/declarations.h>
31 SE_BEGIN_CXX
32
33 /**
34  * A logger which writes to DLT and passes log messages
35  * through to its parent.
36  */
37 class LoggerDLT : public Logger
38 {
39     Handle m_parentLogger;
40     // avoid dependency on dlt.h here
41     void *m_dltContext;
42
43 public:
44     LoggerDLT(const char *appid, const char *description);
45     ~LoggerDLT();
46
47     virtual void messagev(const MessageOptions &options,
48                           const char *format,
49                           va_list args);
50
51     /**
52      * Extracts current log level from the LoggerDLT which was
53      * pushed onto the stack, DLT_LOG_DEFAULT if none active.
54      */
55     static int getCurrentDLTLogLevel();
56 };
57
58 SE_END_CXX
59
60 #endif // USE_DLT
61 #endif // INCL_LOGSYSLOG