Skip to content
Snippets Groups Projects
Commit 28d5b142 authored by Simon McVittie's avatar Simon McVittie
Browse files

Merge branch 'wip/smcv/calm-down-logging' into 'main'

log: Lower noisy messages to debug level

See merge request !598
parents ce104521 b764e66c
No related branches found
No related tags found
1 merge request!598log: Lower noisy messages to debug level
......@@ -1256,40 +1256,40 @@ main (int argc,
if (opt_verbose)
{
g_message ("Command-line:");
g_debug ("Command-line:");
for (i = 0; i < wrapped_command->argv->len - 1; i++)
{
g_autofree gchar *quoted = NULL;
quoted = g_shell_quote (g_ptr_array_index (wrapped_command->argv, i));
g_message ("\t%s", quoted);
g_debug ("\t%s", quoted);
}
g_assert (wrapped_command->argv->pdata[i] == NULL);
g_message ("Environment:");
g_debug ("Environment:");
for (i = 0; wrapped_command->envp != NULL && wrapped_command->envp[i] != NULL; i++)
{
g_autofree gchar *quoted = NULL;
quoted = g_shell_quote (wrapped_command->envp[i]);
g_message ("\t%s", quoted);
g_debug ("\t%s", quoted);
}
g_message ("Inherited file descriptors:");
g_debug ("Inherited file descriptors:");
for (i = 0; i < pass_fds->len; i++)
g_message ("\t%d", g_array_index (pass_fds, int, i));
g_debug ("\t%d", g_array_index (pass_fds, int, i));
g_message ("Redirections:");
g_debug ("Redirections:");
for (i = 0; i < assign_fds->len; i++)
{
const AssignFd *item = &g_array_index (assign_fds, AssignFd, i);
g_message ("\t%d>&%d", item->target, item->source);
g_debug ("\t%d>&%d", item->target, item->source);
}
}
......
......@@ -661,10 +661,10 @@ _srt_util_set_glib_log_handler (const char *prgname,
g_log_set_handler (extra_log_domain, log_levels, log_handler, NULL);
g_log_set_handler (G_LOG_DOMAIN, log_levels, log_handler, NULL);
if ((flags & SRT_LOG_FLAGS_TIMING)
|| ((flags & SRT_LOG_FLAGS_DEBUG)
&& !(flags & SRT_LOG_FLAGS_DIFFABLE)))
_srt_profiling_enable ();
if (flags & SRT_LOG_FLAGS_TIMING)
_srt_profiling_enable (G_LOG_LEVEL_MESSAGE);
else if ((flags & SRT_LOG_FLAGS_DEBUG) && !(flags & SRT_LOG_FLAGS_DIFFABLE))
_srt_profiling_enable (G_LOG_LEVEL_DEBUG);
/* We ensure stdin is open first, because otherwise any fd we open is
* likely to become unintentionally the new stdin. */
......
......@@ -36,5 +36,5 @@ typedef struct _SrtProfilingTimer SrtProfilingTimer;
G_GNUC_PRINTF (1, 2) G_GNUC_INTERNAL
SrtProfilingTimer *_srt_profiling_start (const char *format, ...);
G_GNUC_INTERNAL void _srt_profiling_end (SrtProfilingTimer *start);
G_GNUC_INTERNAL void _srt_profiling_enable (void);
G_GNUC_INTERNAL void _srt_profiling_enable (GLogLevelFlags level);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SrtProfilingTimer, _srt_profiling_end)
......@@ -30,20 +30,26 @@
/* If strictly positive, profiling is enabled. */
static long profiling_ticks_per_sec = 0;
static GLogLevelFlags profiling_level = G_LOG_LEVEL_DEBUG;
/*
* Enable time measurement and profiling messages.
*/
void
_srt_profiling_enable (void)
_srt_profiling_enable (GLogLevelFlags level)
{
errno = 0;
profiling_ticks_per_sec = sysconf (_SC_CLK_TCK);
if (level & G_LOG_LEVEL_MASK)
profiling_level = level;
else
profiling_level = G_LOG_LEVEL_DEBUG;
if (profiling_ticks_per_sec <= 0)
g_warning ("Unable to enable profiling: %s", g_strerror (errno));
else
g_message ("Enabled profiling");
g_log (G_LOG_DOMAIN, profiling_level, "Enabled profiling");
}
struct _SrtProfilingTimer
......@@ -75,7 +81,7 @@ _srt_profiling_start (const char *format,
ret->message = g_strdup_vprintf (format, args);
va_end (args);
g_message ("Profiling: start: %s", ret->message);
g_log (G_LOG_DOMAIN, profiling_level, "Profiling: start: %s", ret->message);
ret->wallclock = times (&ret->cpu);
return ret;
}
......@@ -100,17 +106,18 @@ _srt_profiling_end (SrtProfilingTimer *start)
end = times (&end_cpu);
g_message ("Profiling: end (real %.1fs, user %.1fs, sys %.1fs): %s",
(end - start->wallclock) / (double) profiling_ticks_per_sec,
(end_cpu.tms_utime
+ end_cpu.tms_cutime
- start->cpu.tms_utime
- start->cpu.tms_cutime) / (double) profiling_ticks_per_sec,
(end_cpu.tms_stime
+ end_cpu.tms_cstime
- start->cpu.tms_stime
- start->cpu.tms_cstime) / (double) profiling_ticks_per_sec,
start->message);
g_log (G_LOG_DOMAIN, profiling_level,
"Profiling: end (real %.1fs, user %.1fs, sys %.1fs): %s",
(end - start->wallclock) / (double) profiling_ticks_per_sec,
(end_cpu.tms_utime
+ end_cpu.tms_cutime
- start->cpu.tms_utime
- start->cpu.tms_cutime) / (double) profiling_ticks_per_sec,
(end_cpu.tms_stime
+ end_cpu.tms_cstime
- start->cpu.tms_stime
- start->cpu.tms_cstime) / (double) profiling_ticks_per_sec,
start->message);
g_free (start->message);
g_free (start);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment