From 1668865343c3069a65c241e167618be31a1a0549 Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 13 一月 2017 14:32:30 +0800
Subject: [PATCH] 

---
 RtspFace/logger.h |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/RtspFace/logger.h b/RtspFace/logger.h
index fe50d00..b0b0ffa 100644
--- a/RtspFace/logger.h
+++ b/RtspFace/logger.h
@@ -16,11 +16,25 @@
 #include "log4cpp/FileAppender.hh"
 #include "log4cpp/PatternLayout.hh"
 
+enum LoggerVerbose
+{
+	LV_ERROR,
+	LV_WARN,
+	LV_NOTICE,
+	LV_INFO,
+	LV_DEBUG
+};
 
 #define LOG(__level)  log4cpp::Category::getRoot() << log4cpp::Priority::__level << __FILE__ << ":" << __LINE__ << "\t" 
 #define LOGP(__level, __format, arg...) log4cpp::Category::getRoot().log(log4cpp::Priority::__level, "%s:%d\t" __format, __FILE__, __LINE__, ##arg);
 
-inline void initLogger(int verbose)
+#define LOG_DEBUG    LOG(DEBUG) // Debug message do not care in any production environment
+#define LOG_INFO     LOG(INFO) // Not significant event but useful for deal with online problem
+#define LOG_NOTICE   LOG(NOTICE) // Important event
+#define LOG_WARN     LOG(WARN) // Important event or input which will lead to errors
+#define LOG_ERROR    LOG(ERROR) // Error message means program running in an abnormal (not expected) way
+
+inline void initLogger(LoggerVerbose verbose)
 {
 	// initialize log4cpp
 	log4cpp::Category &log = log4cpp::Category::getRoot();
@@ -37,12 +51,15 @@
 	}
 	switch (verbose)
 	{
-		case 2: log.setPriority(log4cpp::Priority::DEBUG); break;
-		case 1: log.setPriority(log4cpp::Priority::INFO); break;
+		case LV_DEBUG: log.setPriority(log4cpp::Priority::DEBUG); break;
+		case LV_INFO: log.setPriority(log4cpp::Priority::INFO); break;
+		case LV_NOTICE: log.setPriority(log4cpp::Priority::NOTICE); break;
+		case LV_WARN: log.setPriority(log4cpp::Priority::WARN); break;
+		case LV_ERROR: log.setPriority(log4cpp::Priority::ERROR); break;
 		default: log.setPriority(log4cpp::Priority::NOTICE); break;
 		
 	}
-	LOG(INFO) << "level:" << log4cpp::Priority::getPriorityName(log.getPriority()); 
+	LOG_INFO << "level:" << log4cpp::Priority::getPriorityName(log.getPriority()); 
 }
 	
 #endif

--
Gitblit v1.8.0