NeoPZ
pzlog.h
Go to the documentation of this file.
1 
8 #ifndef PZLOGH
9 #define PZLOGH
10 
11 #include <string>
12 #include <sstream>
13 #include <iostream>
14 
15 
16 #include <pz_config.h>
17 #include "pzerror.h"
18 
19 inline void StopError()
20 {
21  std::cout << "Ponto de parada\n";
22  DebugStop();
23 }
24 
25 
26 #ifdef LOG4CXX
27 
28 #include "pz_pthread.h"
29 
30 #include <iostream>
31 #include <log4cxx/logger.h>
32 #include <log4cxx/basicconfigurator.h>
33 #include <log4cxx/propertyconfigurator.h>
34 using namespace log4cxx;
35 using namespace log4cxx::helpers;
36 
37 
42 extern pthread_mutex_t glogmutex;
44 
51 
53 #define LOGPZ_DEBUG(A,B) { \
54  if(A->isDebugEnabled()) { \
55  PZ_PTHREAD_MUTEX_LOCK(&glogmutex,"LOGPZ_DEBUG"); \
56  LOG4CXX_DEBUG(A,B); \
57  PZ_PTHREAD_MUTEX_UNLOCK(&glogmutex,"LOGPZ_DEBUG"); } \
58  else std::cout << "Coloque IsDebugEnabled em " << __FILE__ << ":" << __LINE__ << std::endl;}
59 
61 #define LOGPZ_INFO(A,B) {if(A->isInfoEnabled()) { \
62  PZ_PTHREAD_MUTEX_LOCK(&glogmutex, "LOGPZ_INFO"); \
63  LOG4CXX_INFO(A,B); \
64  PZ_PTHREAD_MUTEX_UNLOCK(&glogmutex, "LOGPZ_INFO"); } }
65 
67 #define LOGPZ_WARN(A,B) {if(A->isWarnEnabled()) { \
68  PZ_PTHREAD_MUTEX_LOCK(&glogmutex,"LOGPZ_WARN"); \
69  LOG4CXX_WARN(A,B); \
70  PZ_PTHREAD_MUTEX_UNLOCK(&glogmutex,"LOGPZ_WARN"); } }
71 
73 #define LOGPZ_ERROR(A,B) {if(A->isErrorEnabled()) { \
74  PZ_PTHREAD_MUTEX_LOCK(&glogmutex,"LOGPZ_ERROR"); \
75  LOG4CXX_ERROR(A,B); StopError(); \
76  PZ_PTHREAD_MUTEX_UNLOCK(&glogmutex,"LOGPZ_ERROR"); } }
77 
79 #define LOGPZ_FATAL(A,B) {if(A->isFatalEnabled()) { \
80  PZ_PTHREAD_MUTEX_LOCK(&glogmutex,"LOGPZ_FATAL"); \
81  LOG4CXX_FATAL(A,B); \
82  PZ_PTHREAD_MUTEX_LOCK(&glogmutex,"LOGPZ_FATAL"); } }
83 
84 #else
85 
87 #define LOGPZ_DEBUG(A,B) {}
88 #define LOGPZ_INFO(A,B) {}
90 #define LOGPZ_WARN(A,B) {}
92 #define LOGPZ_ERROR(A,B) {std::cout << B << std::endl;}
94 #define LOGPZ_FATAL(A,B) {std::cout << B << std::endl;}
96 
97 
98 #endif
99 
106 inline void InitializePZLOG(const std::string &configfile)
107 {
108 #ifdef LOG4CXX
109  log4cxx::PropertyConfigurator::configure(configfile);
110  {
111  log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("pz.mesh.tpzgeoelrefpattern"));
112  logger->setAdditivity(false);
113  // logger->setLevel(log4cxx::Level::getDebug());
114  }
115  {
116  log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("pz.mesh.refpattern"));
117  logger->setAdditivity(false);
118  // logger->setLevel(log4cxx::Level::getDebug());
119  }
120 #endif
121 }
122 
127 void InitializePZLOG();
128 
129 #endif
void StopError()
Definition: pzlog.h:19
Defines PZError.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void InitializePZLOG(const std::string &configfile)
Initialize a log file adequated to use log4cxx lib.
Definition: pzlog.h:106