mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-21 08:23:44 +08:00
Logger: added function logger_get_route_name (#19995)
* added function logger_get_route_name * remove empty line old-commit-hash: 1588a6f0acc3a0f80e0ccaa9f621004d90375fea
This commit is contained in:
@@ -22,16 +22,8 @@ static kj::Array<capnp::word> build_boot_log() {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
char filename[64] = {'\0'};
|
||||
|
||||
time_t rawtime = time(NULL);
|
||||
struct tm timeinfo;
|
||||
|
||||
localtime_r(&rawtime, &timeinfo);
|
||||
strftime(filename, sizeof(filename),
|
||||
"%Y-%m-%d--%H-%M-%S.bz2", &timeinfo);
|
||||
|
||||
std::string path = LOG_ROOT + "/boot/" + std::string(filename);
|
||||
const std::string path = LOG_ROOT + "/boot/" + logger_get_route_name() + ".bz2";
|
||||
LOGW("bootlog to %s", path.c_str());
|
||||
|
||||
// Open bootlog
|
||||
|
||||
@@ -118,6 +118,15 @@ kj::Array<capnp::word> logger_build_init_data() {
|
||||
return capnp::messageToFlatArray(msg);
|
||||
}
|
||||
|
||||
std::string logger_get_route_name() {
|
||||
char route_name[64] = {'\0'};
|
||||
time_t rawtime = time(NULL);
|
||||
struct tm timeinfo;
|
||||
localtime_r(&rawtime, &timeinfo);
|
||||
strftime(route_name, sizeof(route_name), "%Y-%m-%d--%H-%M-%S", &timeinfo);
|
||||
return route_name;
|
||||
}
|
||||
|
||||
void log_init_data(LoggerState *s) {
|
||||
auto bytes = s->init_data.asBytes();
|
||||
logger_log(s, bytes.begin(), bytes.size(), s->has_qlog);
|
||||
@@ -142,15 +151,8 @@ void logger_init(LoggerState *s, const char* log_name, bool has_qlog) {
|
||||
|
||||
s->part = -1;
|
||||
s->has_qlog = has_qlog;
|
||||
|
||||
time_t rawtime = time(NULL);
|
||||
struct tm timeinfo;
|
||||
localtime_r(&rawtime, &timeinfo);
|
||||
|
||||
strftime(s->route_name, sizeof(s->route_name),
|
||||
"%Y-%m-%d--%H-%M-%S", &timeinfo);
|
||||
s->route_name = logger_get_route_name();
|
||||
snprintf(s->log_name, sizeof(s->log_name), "%s", log_name);
|
||||
|
||||
s->init_data = logger_build_init_data();
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ static LoggerHandle* logger_open(LoggerState *s, const char* root_path) {
|
||||
assert(h);
|
||||
|
||||
snprintf(h->segment_path, sizeof(h->segment_path),
|
||||
"%s/%s--%d", root_path, s->route_name, s->part);
|
||||
"%s/%s--%d", root_path, s->route_name.c_str(), s->part);
|
||||
|
||||
snprintf(h->log_path, sizeof(h->log_path), "%s/%s.bz2", h->segment_path, s->log_name);
|
||||
snprintf(h->qlog_path, sizeof(h->qlog_path), "%s/qlog.bz2", h->segment_path);
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct LoggerState {
|
||||
pthread_mutex_t lock;
|
||||
int part;
|
||||
kj::Array<capnp::word> init_data;
|
||||
char route_name[64];
|
||||
std::string route_name;
|
||||
char log_name[64];
|
||||
bool has_qlog;
|
||||
|
||||
@@ -75,6 +75,7 @@ typedef struct LoggerState {
|
||||
|
||||
int logger_mkpath(char* file_path);
|
||||
kj::Array<capnp::word> logger_build_init_data();
|
||||
std::string logger_get_route_name();
|
||||
void logger_init(LoggerState *s, const char* log_name, bool has_qlog);
|
||||
int logger_next(LoggerState *s, const char* root_path,
|
||||
char* out_segment_path, size_t out_segment_path_len,
|
||||
|
||||
Reference in New Issue
Block a user