|
|
@ -30,22 +30,6 @@ 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))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int logger_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, 0775)==-1) { |
|
|
|
|
|
|
|
if (errno != EEXIST) { |
|
|
|
|
|
|
|
*p = '/'; |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*p = '/'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***** log metadata *****
|
|
|
|
// ***** log metadata *****
|
|
|
|
kj::Array<capnp::word> logger_build_init_data() { |
|
|
|
kj::Array<capnp::word> logger_build_init_data() { |
|
|
|
MessageBuilder msg; |
|
|
|
MessageBuilder msg; |
|
|
@ -154,8 +138,6 @@ void logger_init(LoggerState *s, const char* log_name, bool has_qlog) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { |
|
|
|
static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { |
|
|
|
int err; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LoggerHandle *h = NULL; |
|
|
|
LoggerHandle *h = NULL; |
|
|
|
for (int i=0; i<LOGGER_MAX_HANDLES; i++) { |
|
|
|
for (int i=0; i<LOGGER_MAX_HANDLES; i++) { |
|
|
|
if (s->handles[i].refcnt == 0) { |
|
|
|
if (s->handles[i].refcnt == 0) { |
|
|
@ -174,8 +156,7 @@ static LoggerHandle* logger_open(LoggerState *s, const char* root_path) { |
|
|
|
h->end_sentinel_type = SentinelType::END_OF_SEGMENT; |
|
|
|
h->end_sentinel_type = SentinelType::END_OF_SEGMENT; |
|
|
|
h->exit_signal = 0; |
|
|
|
h->exit_signal = 0; |
|
|
|
|
|
|
|
|
|
|
|
err = logger_mkpath(h->log_path); |
|
|
|
if (!util::create_directories(h->segment_path, 0775)) return nullptr; |
|
|
|
if (err) return NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE* lock_file = fopen(h->lock_path, "wb"); |
|
|
|
FILE* lock_file = fopen(h->lock_path, "wb"); |
|
|
|
if (lock_file == NULL) return NULL; |
|
|
|
if (lock_file == NULL) return NULL; |
|
|
|