server : change message format of server_log()
This commit is contained in:
parent
65e65fd6c0
commit
f23aa90994
2 changed files with 27 additions and 19 deletions
|
@ -2593,13 +2593,15 @@ static json format_partial_response(
|
||||||
static json format_tokenizer_response(const std::vector<llama_token> &tokens)
|
static json format_tokenizer_response(const std::vector<llama_token> &tokens)
|
||||||
{
|
{
|
||||||
return json {
|
return json {
|
||||||
{"tokens", tokens}};
|
{"tokens", tokens}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static json format_detokenized_response(std::string content)
|
static json format_detokenized_response(std::string content)
|
||||||
{
|
{
|
||||||
return json {
|
return json {
|
||||||
{"content", content}};
|
{"content", content}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ extern bool server_verbose;
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG_ERROR( MSG, ...) server_log("ERROR", __func__, __LINE__, MSG, __VA_ARGS__)
|
#define LOG_ERROR( MSG, ...) server_log("ERR", __func__, __LINE__, MSG, __VA_ARGS__)
|
||||||
#define LOG_WARNING(MSG, ...) server_log("WARNING", __func__, __LINE__, MSG, __VA_ARGS__)
|
#define LOG_WARNING(MSG, ...) server_log("WARN", __func__, __LINE__, MSG, __VA_ARGS__)
|
||||||
#define LOG_INFO( MSG, ...) server_log("INFO", __func__, __LINE__, MSG, __VA_ARGS__)
|
#define LOG_INFO( MSG, ...) server_log("INFO", __func__, __LINE__, MSG, __VA_ARGS__)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -136,19 +136,25 @@ struct completion_token_output
|
||||||
static inline void server_log(const char *level, const char *function, int line,
|
static inline void server_log(const char *level, const char *function, int line,
|
||||||
const char *message, const nlohmann::ordered_json &extra)
|
const char *message, const nlohmann::ordered_json &extra)
|
||||||
{
|
{
|
||||||
nlohmann::ordered_json log
|
char buf[1024];
|
||||||
{
|
snprintf(buf, 1024, "%24s %4s: %-80s", function, level, message);
|
||||||
{"timestamp", time(nullptr)},
|
|
||||||
{"level", level},
|
|
||||||
{"function", function},
|
|
||||||
{"line", line},
|
|
||||||
{"message", message},
|
|
||||||
};
|
|
||||||
|
|
||||||
auto thread_id = std::this_thread::get_id();
|
nlohmann::ordered_json log;
|
||||||
|
|
||||||
|
{
|
||||||
std::stringstream ss_thread_id;
|
std::stringstream ss_thread_id;
|
||||||
ss_thread_id << thread_id;
|
ss_thread_id << std::this_thread::get_id();
|
||||||
log.push_back({"thread_id", ss_thread_id.str()});
|
log.push_back({"tid", ss_thread_id.str()});
|
||||||
|
}
|
||||||
|
|
||||||
|
log.merge_patch(
|
||||||
|
{
|
||||||
|
//{"timestamp", time(nullptr)},
|
||||||
|
//{"level", level},
|
||||||
|
//{"function", function},
|
||||||
|
//{"line", line},
|
||||||
|
{"msg", buf},
|
||||||
|
});
|
||||||
|
|
||||||
if (!extra.empty())
|
if (!extra.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue