20 std::ofstream
log(
"debugging.log", std::ios::trunc);
67 default:
return "UNKNOWN";
85 std::cerr <<
"[LOGGER_ERROR] Failed to open log file: " <<
log_file_path_ << std::endl;
96 std::cerr <<
"[LOGGER_ERROR] Failed to re-open/truncate log file: " <<
log_file_path_ << std::endl;
109 auto now = std::chrono::system_clock::now();
110 auto now_c = std::chrono::system_clock::to_time_t(
now);
156 std::cerr <<
"[FATAL] " <<
message << std::endl;
161 const std::vector<float>&
v,
int n_show) {
171 for (
float val :
v) {
172 if (std::isnan(
val) || std::isinf(
val)) {
181 std::ostringstream
oss;
182 oss <<
name <<
": size=" <<
v.size()
188 for (
int i = 0;
i < std::min((
int)
v.size(),
n_show); ++
i) {
189 oss <<
v[
i] << (
i == std::min((
int)
v.size(),
n_show) - 1 ?
"" :
", ");
210 float mean_val =
static_cast<float>(
static_cast<double>(
sum_val) /
v.size());
212 std::ostringstream
oss;
213 oss <<
name <<
": size=" <<
v.size()
214 <<
", min=" <<
static_cast<int>(
min_val)
215 <<
", max=" <<
static_cast<int>(
max_val)
218 for (
int i = 0;
i < std::min((
int)
v.size(),
n_show); ++
i) {
226 std::ostringstream
oss;
234 std::ostringstream
oss;
235 oss <<
"0x" << std::hex << static_cast<unsigned long long>(
val);
static void log_vector_stats(const std::string &name, const std::vector< float > &v, int n_show=5)
static bool log_file_truncated_
static std::string log_file_path_
static void debug(const std::string &message)
static std::string to_hex(T val)
static void log_internal(Level level, const std::string &message)
static void warning(const std::string &message)
static std::string ptrToString(const void *ptr)
static void ensure_logfile_open_and_truncated()
static bool console_enabled_
static void set_level(Level new_level)
static void enable_console(bool enabled)
static std::string level_to_string(Level level)
static Level current_level_
static std::string uint16ToHex(uint16_t val)
static std::ofstream log_file_stream_
static void info(const std::string &message)
static void error(const std::string &message)
static void fatal(const std::string &message)
static void log_vector_stats_int8(const std::string &name, const std::vector< int8_t > &v, int n_show=5)
static void critical(const std::string &message)
static void set_logfile(const std::string &filename)
Logging utilities for the TinyLlama implementation.