log : do not append to existing log + disable file line func by default

This commit is contained in:
Georgi Gerganov 2023-08-29 13:59:55 +03:00
parent b97958a511
commit 6b4c65be83
No known key found for this signature in database
GPG key ID: 449E073F9DC10735
2 changed files with 9 additions and 8 deletions

View file

@ -4,6 +4,7 @@
#include "llama.h" #include "llama.h"
#define LOG_NO_FILE_LINE_FUNCTION
#include "log.h" #include "log.h"
#include <string> #include <string>

View file

@ -90,11 +90,11 @@
// } // }
// //
#ifndef LOG_TARGET #ifndef LOG_TARGET
#define LOG_TARGET log_handler() #define LOG_TARGET log_handler()
#endif #endif
#ifndef LOG_TEE_TARGET #ifndef LOG_TEE_TARGET
#define LOG_TEE_TARGET stderr #define LOG_TEE_TARGET stderr
#endif #endif
// Utility to obtain "pid" like unique process id and use it when creating log files. // Utility to obtain "pid" like unique process id and use it when creating log files.
@ -147,10 +147,10 @@ inline std::string _log_filename_generator(const std::string & log_file_basename
// //
#ifndef LOG_NO_TIMESTAMPS #ifndef LOG_NO_TIMESTAMPS
/**/#ifndef _WIN32 /**/#ifndef _WIN32
/* */#define LOG_TIMESTAMP_FMT "[%" PRIu64 "]" /* */#define LOG_TIMESTAMP_FMT "[%" PRIu64 "] "
/* */#define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count() /* */#define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
/**/#else /**/#else
/* */#define LOG_TIMESTAMP_FMT "[%" PRIu64 "]" /* */#define LOG_TIMESTAMP_FMT "[%" PRIu64 "] "
/* */#define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count() /* */#define LOG_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
/**/#endif /**/#endif
#else #else
@ -160,10 +160,10 @@ inline std::string _log_filename_generator(const std::string & log_file_basename
#ifdef LOG_TEE_TIMESTAMPS #ifdef LOG_TEE_TIMESTAMPS
/**/#ifndef _WIN32 /**/#ifndef _WIN32
/* */#define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "]" /* */#define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "] "
/* */#define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count() /* */#define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
/**/#else /**/#else
/* */#define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "]" /* */#define LOG_TEE_TIMESTAMP_FMT "[%" PRIu64 "] "
/* */#define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count() /* */#define LOG_TEE_TIMESTAMP_VAL , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count()
/**/#endif /**/#endif
#else #else
@ -378,11 +378,11 @@ inline FILE *_log_handler1(bool change = false, LogTriState disable = LogTriStat
} }
logfile = nullptr; logfile = nullptr;
logfile = fopen(filename.c_str(), "a"); logfile = fopen(filename.c_str(), "w");
} }
else else
{ {
logfile = fopen(filename.c_str(), "a"); logfile = fopen(filename.c_str(), "w");
} }
} }