MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / print

Method print

smallthinker/common/log.cpp:60–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 bool is_end;
59
60 void print(FILE * file = nullptr) const {
61 FILE * fcur = file;
62 if (!fcur) {
63 // stderr displays DBG messages only when their verbosity level is not higher than the threshold
64 // these messages will still be logged to a file
65 if (level == GGML_LOG_LEVEL_DEBUG && common_log_verbosity_thold < LOG_DEFAULT_DEBUG) {
66 return;
67 }
68
69 fcur = stdout;
70
71 if (level != GGML_LOG_LEVEL_NONE) {
72 fcur = stderr;
73 }
74 }
75
76 if (level != GGML_LOG_LEVEL_NONE && level != GGML_LOG_LEVEL_CONT && prefix) {
77 if (timestamp) {
78 // [M.s.ms.us]
79 fprintf(fcur, "%s%d.%02d.%03d.%03d%s ",
80 g_col[COMMON_LOG_COL_BLUE],
81 (int) (timestamp / 1000000 / 60),
82 (int) (timestamp / 1000000 % 60),
83 (int) (timestamp / 1000 % 1000),
84 (int) (timestamp % 1000),
85 g_col[COMMON_LOG_COL_DEFAULT]);
86 }
87
88 switch (level) {
89 case GGML_LOG_LEVEL_INFO: fprintf(fcur, "%sI %s", g_col[COMMON_LOG_COL_GREEN], g_col[COMMON_LOG_COL_DEFAULT]); break;
90 case GGML_LOG_LEVEL_WARN: fprintf(fcur, "%sW %s", g_col[COMMON_LOG_COL_MAGENTA], "" ); break;
91 case GGML_LOG_LEVEL_ERROR: fprintf(fcur, "%sE %s", g_col[COMMON_LOG_COL_RED], "" ); break;
92 case GGML_LOG_LEVEL_DEBUG: fprintf(fcur, "%sD %s", g_col[COMMON_LOG_COL_YELLOW], "" ); break;
93 default:
94 break;
95 }
96 }
97
98 fprintf(fcur, "%s", msg.data());
99
100 if (level == GGML_LOG_LEVEL_WARN || level == GGML_LOG_LEVEL_ERROR || level == GGML_LOG_LEVEL_DEBUG) {
101 fprintf(fcur, "%s", g_col[COMMON_LOG_COL_DEFAULT]);
102 }
103
104 fflush(fcur);
105 }
106};
107
108struct common_log {

Callers 1

resumeMethod · 0.45

Calls 2

fprintfFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected