LoggingMacros_SLOGGING.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 #ifndef ICL_CORE_LOGGING_LOGGING_MACROS__SLOGGING_H_INCLUDED
28 #define ICL_CORE_LOGGING_LOGGING_MACROS__SLOGGING_H_INCLUDED
29 
30 #ifdef __ANDROID__
31 #include <android/log.h>
32 #include <sstream>
33 #endif
34 
35 #ifdef __ANDROID__
36 #define SLOGGING_LOG_FLCO(stream, level, filename, line, classname, objectname, arg) \
37  do { \
38  if (stream.isActive()) \
39  { \
40  if (stream.getLogLevel() <= level) \
41  { \
42  std::stringstream str; \
43  str << arg; \
44  switch (level) { \
45  case ::icl_core::logging::eLL_TRACE: __android_log_print(ANDROID_LOG_VERBOSE, stream.nameCStr(), str.str().c_str()); break; \
46  case ::icl_core::logging::eLL_DEBUG: __android_log_print(ANDROID_LOG_DEBUG, stream.nameCStr(), str.str().c_str()); break; \
47  case ::icl_core::logging::eLL_INFO: __android_log_print(ANDROID_LOG_INFO, stream.nameCStr(), str.str().c_str()); break; \
48  case ::icl_core::logging::eLL_WARNING: __android_log_print(ANDROID_LOG_WARN, stream.nameCStr(), str.str().c_str()); break; \
49  default: __android_log_print(ANDROID_LOG_UNKNOWN, stream.nameCStr(), str.str().c_str()); break; \
50  } \
51  } \
52  } \
53  } while (0)
54 #else
55 #define SLOGGING_LOG_FLCO(stream, level, filename, line, classname, objectname, arg) \
56  do { \
57  if (stream.isActive()) \
58  { \
59  if (stream.getLogLevel() <= level) \
60  { \
61  ::icl_core::logging::ThreadStream& thread_stream=stream.threadStream(level); \
62  thread_stream.setLineLogLevel(level); \
63  thread_stream.setFilename(filename); \
64  thread_stream.setLine(line); \
65  thread_stream.setClassname(classname); \
66  thread_stream.setObjectname(objectname); \
67  thread_stream.setFunction(__FUNCTION__); \
68  thread_stream << arg; \
69  } \
70  } \
71  } while (0)
72 #endif
73 #define SLOGGING_LOG_CO(stream, level, classname, objectname, arg) SLOGGING_LOG_FLCO(stream, level, __FILE__, __LINE__, #classname, objectname, arg)
74 #define SLOGGING_LOG_C(stream, level, classname, arg) SLOGGING_LOG_FLCO(stream, level, __FILE__, __LINE__, #classname, "", arg)
75 #define SLOGGING_LOG(stream, level, arg) SLOGGING_LOG_FLCO(stream, level, __FILE__, __LINE__, "", "", arg)
76 
77 
78 #define SLOGGING_ERROR(stream, arg) SLOGGING_LOG(stream, ::icl_core::logging::eLL_ERROR, arg)
79 #define SLOGGING_WARNING(stream, arg) SLOGGING_LOG(stream, ::icl_core::logging::eLL_WARNING, arg)
80 #define SLOGGING_INFO(stream, arg) SLOGGING_LOG(stream, ::icl_core::logging::eLL_INFO, arg)
81 #ifdef _IC_DEBUG_
82 # define SLOGGING_DEBUG(stream, arg) SLOGGING_LOG(stream, ::icl_core::logging::eLL_DEBUG, arg)
83 # define SLOGGING_TRACE(stream, arg) SLOGGING_LOG(stream, ::icl_core::logging::eLL_TRACE, arg)
84 #else
85 # define SLOGGING_DEBUG(stream, arg) (void)0
86 # define SLOGGING_TRACE(stream, arg) (void)0
87 #endif
88 
89 
90 #define SLOGGING_ERROR_C(stream, classname, arg) SLOGGING_LOG_C(stream, ::icl_core::logging::eLL_ERROR, classname, arg)
91 #define SLOGGING_WARNING_C(stream, classname, arg) SLOGGING_LOG_C(stream, ::icl_core::logging::eLL_WARNING, classname, arg)
92 #define SLOGGING_INFO_C(stream, classname, arg) SLOGGING_LOG_C(stream, ::icl_core::logging::eLL_INFO, classname, arg)
93 #ifdef _IC_DEBUG_
94 # define SLOGGING_DEBUG_C(stream, classname, arg) SLOGGING_LOG_C(stream, ::icl_core::logging::eLL_DEBUG, classname, arg)
95 # define SLOGGING_TRACE_C(stream, classname, arg) SLOGGING_LOG_C(stream, ::icl_core::logging::eLL_TRACE, classname, arg)
96 #else
97 # define SLOGGING_DEBUG_C(stream, classname, arg) (void)0
98 # define SLOGGING_TRACE_C(stream, classname, arg) (void)0
99 #endif
100 
101 
102 #define SLOGGING_ERROR_CO(stream, classname, objectname, arg) SLOGGING_LOG_CO(stream, ::icl_core::logging::eLL_ERROR, classname, objectname, arg)
103 #define SLOGGING_WARNING_CO(stream, classname, objectname, arg) SLOGGING_LOG_CO(stream, ::icl_core::logging::eLL_WARNING, classname, objectname, arg)
104 #define SLOGGING_INFO_CO(stream, classname, objectname, arg) SLOGGING_LOG_CO(stream, ::icl_core::logging::eLL_INFO, classname, objectname, arg)
105 #ifdef _IC_DEBUG_
106 # define SLOGGING_DEBUG_CO(stream, classname, objectname, arg) SLOGGING_LOG_CO(stream, ::icl_core::logging::eLL_DEBUG, classname, objectname, arg)
107 # define SLOGGING_TRACE_CO(stream, classname, objectname, arg) SLOGGING_LOG_CO(stream, ::icl_core::logging::eLL_TRACE, classname, objectname, arg)
108 #else
109 # define SLOGGING_DEBUG_CO(stream, classname, objectname, arg) (void)0
110 # define SLOGGING_TRACE_CO(stream, classname, objectname, arg) (void)0
111 #endif
112 
113 
114 #endif


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58