wslog: Use plain format with "message" level

Try out a simpler format with the default log level.

Don't display process and file/function information with "message"
level (experimental).
This commit is contained in:
João Valverde 2021-06-16 01:07:37 +01:00
parent 790bbbe16d
commit 05ed76d4c0
3 changed files with 36 additions and 25 deletions

View File

@ -457,6 +457,8 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
# in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
/DPSAPI_VERSION=1
/D_ALLOW_KEYWORD_MACROS
# https://stackoverflow.com/questions/37845163/what-is-the-purpose-of-microsofts-underscore-c-functions
/D_CRT_NONSTDC_NO_WARNINGS
)
if(NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64")

View File

@ -977,7 +977,7 @@ int main(int argc, char *qt_argv[])
}
wsApp->allSystemsGo();
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Wireshark is up and ready to go, elapsed time %.3fs\n", (float) (g_get_monotonic_time() - start_time) / 1000000);
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_MESSAGE, "Wireshark is up and ready to go, elapsed time %.3fs", (float) (g_get_monotonic_time() - start_time) / 1000000);
SimpleDialog::displayQueuedMessages(main_w);
/* User could specify filename, or display filter, or both */

View File

@ -17,6 +17,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <process.h>
#endif
#include <ws_attributes.h>
#include <wsutil/ws_assert.h>
@ -334,35 +337,41 @@ static void log_write_do_work(FILE *fp, gboolean use_color, const char *timestam
const char *file, int line, const char *func,
const char *user_format, va_list user_ap)
{
#ifndef _WIN32
fprintf(fp, " ** (%s:%ld) ",
registered_appname ? registered_appname : "PID", (long)getpid());
#else
if (registered_appname)
fprintf(fp, " ** (%s) ", registered_appname);
else
fprintf(fp, " ** ");
#endif
if (timestamp)
fputs(timestamp, fp);
const char *level_str = ws_log_level_to_string(level);
gboolean doextra = (level != LOG_LEVEL_MESSAGE);
if (strcmp(domain, LOG_DOMAIN_DEFAULT) != 0)
fprintf(fp, " [%s-%s]", domain, level_str);
else
fprintf(fp, " [%s]", level_str);
if (doextra) {
fprintf(fp, " ** (%s:%ld) ", registered_appname ?
registered_appname : "PID", (long)getpid());
}
else {
fputs(" ** ", fp);
}
if (file && line >= 0)
fprintf(fp, " %s:%d", file, line);
else if (file)
fprintf(fp, " %s", file);
if (timestamp) {
fputs(timestamp, fp);
fputc(' ', fp);
}
fputs(" -- ", fp);
if (strcmp(domain, LOG_DOMAIN_DEFAULT) != 0) {
fprintf(fp, "[%s-%s] ", domain, level_str);
}
else {
fprintf(fp, "[%s] ", level_str);
}
if (func)
fprintf(fp, "%s%s()%s: " , color_on(use_color), func, color_off(use_color));
if (doextra) {
if (file && line >= 0) {
fprintf(fp, "%s:%d ", file, line);
}
else if (file) {
fprintf(fp, "%s ", file);
}
fputs("-- ", fp);
if (func) {
fprintf(fp, "%s%s()%s: " , color_on(use_color), func, color_off(use_color));
}
}
vfprintf(fp, user_format, user_ap);
fputc('\n', fp);