|  |  | @ -6,7 +6,6 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <assert.h> |  |  |  | #include <assert.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <time.h> |  |  |  | #include <time.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <errno.h> |  |  |  | #include <errno.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <unistd.h> |  |  |  | #include <unistd.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <sys/stat.h> |  |  |  | #include <sys/stat.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -18,14 +17,17 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #ifdef QCOM |  |  |  | #ifdef QCOM | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <cutils/properties.h> |  |  |  | #include <cutils/properties.h> | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif |  |  |  | #endif | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "messaging.hpp" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "common/swaglog.h" |  |  |  | #include "common/swaglog.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "common/params.h" |  |  |  | #include "common/params.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "common/util.h" |  |  |  | #include "common/util.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "common/version.h" |  |  |  | #include "common/version.h" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include "messaging.hpp" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "logger.h" |  |  |  | #include "logger.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | // ***** logging helpers *****
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void append_property(const char* key, const char* value, void *cookie) { |  |  |  | void append_property(const char* key, const char* value, void *cookie) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   std::vector<std::pair<std::string, std::string> > *properties = |  |  |  |   std::vector<std::pair<std::string, std::string> > *properties = | 
			
		
	
		
		
			
				
					
					|  |  |  |     (std::vector<std::pair<std::string, std::string> > *)cookie; |  |  |  |     (std::vector<std::pair<std::string, std::string> > *)cookie; | 
			
		
	
	
		
		
			
				
					|  |  | @ -33,6 +35,24 @@ void append_property(const char* key, const char* value, void *cookie) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   properties->push_back(std::make_pair(std::string(key), std::string(value))); |  |  |  |   properties->push_back(std::make_pair(std::string(key), std::string(value))); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | static int mkpath(char* file_path) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   assert(file_path && *file_path); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   char* p; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     *p = '\0'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (mkdir(file_path, 0777)==-1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if (errno != EEXIST) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         *p = '/'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return -1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     *p = '/'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | // ***** log metadata *****
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void log_init_data(LoggerState *s) { |  |  |  | void log_init_data(LoggerState *s) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   MessageBuilder msg; |  |  |  |   MessageBuilder msg; | 
			
		
	
		
		
			
				
					
					|  |  |  |   auto init = msg.initEvent().initInitData(); |  |  |  |   auto init = msg.initEvent().initInitData(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -114,21 +134,7 @@ static void log_sentinel(LoggerState *s, cereal::Sentinel::SentinelType type) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   logger_log(s, bytes.begin(), bytes.size(), true); |  |  |  |   logger_log(s, bytes.begin(), bytes.size(), true); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static int mkpath(char* file_path) { |  |  |  | // ***** logging functions *****
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   assert(file_path && *file_path); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   char* p; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     *p = '\0'; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (mkdir(file_path, 0777)==-1) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (errno != EEXIST) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *p = '/'; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         return -1; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     *p = '/'; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return 0; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void logger_init(LoggerState *s, const char* log_name, bool has_qlog) { |  |  |  | void logger_init(LoggerState *s, const char* log_name, bool has_qlog) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   memset(s, 0, sizeof(*s)); |  |  |  |   memset(s, 0, sizeof(*s)); | 
			
		
	
	
		
		
			
				
					|  |  | @ -194,8 +200,8 @@ static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   pthread_mutex_init(&h->lock, NULL); |  |  |  |   pthread_mutex_init(&h->lock, NULL); | 
			
		
	
		
		
			
				
					
					|  |  |  |   h->refcnt++; |  |  |  |   h->refcnt++; | 
			
		
	
		
		
			
				
					
					|  |  |  |   log_init_data(s); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return h; |  |  |  |   return h; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | fail: |  |  |  | fail: | 
			
		
	
		
		
			
				
					
					|  |  |  |   LOGE("logger failed to open files"); |  |  |  |   LOGE("logger failed to open files"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (h->bz_file) { |  |  |  |   if (h->bz_file) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -246,6 +252,8 @@ int logger_next(LoggerState *s, const char* root_path, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   pthread_mutex_unlock(&s->lock); |  |  |  |   pthread_mutex_unlock(&s->lock); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   // write beggining of log metadata
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   log_init_data(s); | 
			
		
	
		
		
			
				
					
					|  |  |  |   log_sentinel(s, is_start_of_route ? cereal::Sentinel::SentinelType::START_OF_ROUTE : cereal::Sentinel::SentinelType::START_OF_SEGMENT); |  |  |  |   log_sentinel(s, is_start_of_route ? cereal::Sentinel::SentinelType::START_OF_ROUTE : cereal::Sentinel::SentinelType::START_OF_SEGMENT); | 
			
		
	
		
		
			
				
					
					|  |  |  |   return 0; |  |  |  |   return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |