Add log init message to main()

This commit is contained in:
João Valverde 2022-10-06 18:41:17 +01:00
parent 68a581afdc
commit 3949d289d1
18 changed files with 57 additions and 11 deletions

View File

@ -42,6 +42,7 @@
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -1611,6 +1612,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
/* Get the decimal point. */
decimal_point = g_strdup(localeconv()->decimal_point);

View File

@ -12,6 +12,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -121,6 +122,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, 1);
ws_noisy("Finished log init and parsing command line log arguments");
/* Initialize the version information. */
ws_init_version_info("Captype", NULL, NULL);

View File

@ -9,6 +9,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdlib.h>
#include <stdio.h>
@ -84,6 +85,8 @@ main(int argc, char **argv)
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, 1);
ws_noisy("Finished log init and parsing command line log arguments");
/*
* Get credential information for later use.
*/

View File

@ -4910,6 +4910,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, 1);
ws_noisy("Finished log init and parsing command line log arguments");
#ifdef _WIN32
create_app_running_mutex();

View File

@ -16,6 +16,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -1187,6 +1188,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
#ifdef _WIN32
create_app_running_mutex();
#endif /* _WIN32 */

View File

@ -169,6 +169,7 @@ void extcap_log_init(const char *progname)
ws_log_init(progname, NULL);
/* extcaps cannot write debug information to parent on stderr. */
ws_log_console_writer_set_use_stdout(TRUE);
ws_noisy("Extcap log initialization finished");
}
uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument)

View File

@ -10,6 +10,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdlib.h>
#include <stdio.h>
@ -244,6 +245,8 @@ fuzz_init(int argc _U_, char **argv)
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, LOG_ARGS_NOEXIT);
ws_noisy("Finished log init and parsing command line log arguments");
/*
* Get credential information for later use, and drop privileges
* before doing anything else.

View File

@ -12,6 +12,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -225,6 +226,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, 1);
ws_noisy("Finished log init and parsing command line log arguments");
#ifdef _WIN32
create_app_running_mutex();
#endif /* _WIN32 */

View File

@ -10,6 +10,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <glib.h>
@ -135,6 +136,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
/*
* Get credential information for later use.
*/

View File

@ -21,6 +21,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdlib.h>
#include <stdio.h>
@ -450,6 +451,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
/* Initialize the version information. */
ws_init_version_info("Rawshark",
epan_gather_compile_info,

View File

@ -9,6 +9,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -206,6 +207,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
/* Initialize the version information. */
ws_init_version_info("Reordercap", NULL, NULL);

View File

@ -10,6 +10,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdlib.h>
#include <stdio.h>
@ -124,6 +125,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INIT_FAILED);
ws_noisy("Finished log init and parsing command line log arguments");
/*
* Get credential information for later use, and drop privileges
* before doing anything else.

View File

@ -65,6 +65,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <stdio.h>
#include <stdlib.h>
@ -1010,6 +1011,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
#ifdef _WIN32
create_app_running_mutex();
#endif /* _WIN32 */

View File

@ -341,6 +341,8 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
#ifdef _WIN32
create_app_running_mutex();
#endif /* _WIN32 */

View File

@ -866,6 +866,7 @@ main(int argc, char *argv[])
/* Early logging command-line initialization. */
ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
ws_noisy("Finished log init and parsing command line log arguments");
ws_debug("tshark started with %d args", argc);
#ifdef _WIN32

View File

@ -8,6 +8,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <glib.h>
@ -486,6 +487,7 @@ int main(int argc, char *qt_argv[])
ws_log_init_with_writer("logray", console_log_writer, vcmdarg_err);
/* For backward compatibility with GLib logging and Wireshark 3.4. */
ws_log_console_writer_set_use_stdout(TRUE);
ws_noisy("Finished log init and parsing command line log arguments");
qInstallMessageHandler(qt_log_message_handler);

View File

@ -8,6 +8,7 @@
*/
#include <config.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
#include <glib.h>
@ -488,6 +489,7 @@ int main(int argc, char *qt_argv[])
ws_log_init_with_writer("wireshark", console_log_writer, vcmdarg_err);
/* For backward compatibility with GLib logging and Wireshark 3.4. */
ws_log_console_writer_set_use_stdout(TRUE);
ws_noisy("Finished log init and parsing command line log arguments");
qInstallMessageHandler(qt_log_message_handler);

View File

@ -37,6 +37,12 @@
#include "strtoi.h"
#ifndef WS_DISABLE_ASSERT
#define ASSERT(expr) assert(expr)
#else
#define ASSERT(expr) (void)(expr);
#endif
/* Runtime log level. */
#define ENV_VAR_LEVEL "WIRESHARK_LOG_LEVEL"
@ -118,9 +124,7 @@ static FILE *custom_log = NULL;
static enum ws_log_level fatal_log_level = LOG_LEVEL_ERROR;
#ifndef WS_DISABLE_DEBUG
static bool init_complete = false;
#endif
static void print_err(void (*vcmdarg_err)(const char *, va_list ap),
@ -371,7 +375,7 @@ parse_console_compat_option(char *argv[],
uint32_t mask;
enum ws_log_level level;
assert(argv != NULL);
ASSERT(argv != NULL);
if (argv[0] == NULL)
return;
@ -440,8 +444,8 @@ parse_console_compat_option(char *argv[],
/* Match "arg_name=value" or "arg_name value" to opt_name. */
static bool optequal(const char *arg, const char *opt)
{
ws_assert(arg);
ws_assert(opt);
ASSERT(arg);
ASSERT(opt);
#define ARGEND(arg) (*(arg) == '\0' || *(arg) == ' ' || *(arg) == '=')
while (!ARGEND(arg) && *opt != '\0') {
@ -471,6 +475,9 @@ int ws_log_parse_args(int *argc_ptr, char *argv[],
if (argc_ptr == NULL || argv == NULL)
return -1;
/* Assert ws_log_init() was called before ws_log_parse_args(). */
ASSERT(init_complete);
/* Configure from command line. */
while (*ptr != NULL) {
@ -636,8 +643,8 @@ static void tokenize_filter_str(log_filter_t **filter_ptr,
bool negated = false;
log_filter_t *filter;
assert(filter_ptr);
assert(*filter_ptr == NULL);
ASSERT(filter_ptr);
ASSERT(*filter_ptr == NULL);
if (str_filter == NULL)
return;
@ -846,9 +853,7 @@ void ws_log_init(const char *progname,
if (env != NULL)
ws_log_set_noisy_filter(env);
#ifndef WS_DISABLE_DEBUG
init_complete = true;
#endif
}
@ -925,10 +930,8 @@ static void log_write_do_work(FILE *fp, bool use_color,
const char *file, long line, const char *func,
const char *user_format, va_list user_ap)
{
#ifndef WS_DISABLE_DEBUG
if (!init_complete)
fputs(" ** (noinit)", fp);
#endif
/* Process */
fprintf(fp, " ** (%s:%ld) ", registered_progname, (long)getpid());