log: only include LOC and method name in debug logs if running with --debug
If the modem is started with --log-level=DEBUG, they will not be shown.
This commit is contained in:
@@ -115,6 +115,7 @@ main (int argc, char *argv[])
|
||||
mm_context_get_log_file (),
|
||||
mm_context_get_timestamps (),
|
||||
mm_context_get_relative_timestamps (),
|
||||
mm_context_get_debug (),
|
||||
&err)) {
|
||||
g_warning ("Failed to set up logging: %s", err->message);
|
||||
g_error_free (err);
|
||||
|
@@ -39,6 +39,7 @@ static gboolean ts_flags = TS_FLAG_NONE;
|
||||
static guint32 log_level = LOGL_INFO | LOGL_WARN | LOGL_ERR;
|
||||
static GTimeVal rel_start = { 0, 0 };
|
||||
static int logfd = -1;
|
||||
static gboolean func_loc = FALSE;
|
||||
|
||||
typedef struct {
|
||||
guint32 num;
|
||||
@@ -108,7 +109,7 @@ _mm_log (const char *loc,
|
||||
g_warn_if_reached ();
|
||||
|
||||
if (prefix) {
|
||||
if (log_level & LOGL_DEBUG)
|
||||
if (func_loc && log_level & LOGL_DEBUG)
|
||||
snprintf (msgbuf, sizeof (msgbuf), "%s%s [%s] %s(): %s\n", prefix, tsbuf, loc, func, msg);
|
||||
else
|
||||
snprintf (msgbuf, sizeof (msgbuf), "%s%s %s\n", prefix, tsbuf, msg);
|
||||
@@ -189,12 +190,15 @@ mm_log_setup (const char *level,
|
||||
const char *log_file,
|
||||
gboolean show_timestamps,
|
||||
gboolean rel_timestamps,
|
||||
gboolean debug_func_loc,
|
||||
GError **error)
|
||||
{
|
||||
/* levels */
|
||||
if (level && strlen (level) && !mm_log_set_level (level, error))
|
||||
return FALSE;
|
||||
|
||||
func_loc = debug_func_loc;
|
||||
|
||||
if (show_timestamps)
|
||||
ts_flags = TS_FLAG_WALL;
|
||||
else if (rel_timestamps)
|
||||
@@ -238,4 +242,3 @@ mm_log_shutdown (void)
|
||||
else
|
||||
close (logfd);
|
||||
}
|
||||
|
||||
|
@@ -53,6 +53,7 @@ gboolean mm_log_setup (const char *level,
|
||||
const char *log_file,
|
||||
gboolean show_ts,
|
||||
gboolean rel_ts,
|
||||
gboolean debug_func_loc,
|
||||
GError **error);
|
||||
|
||||
void mm_log_usr1 (void);
|
||||
@@ -60,4 +61,3 @@ void mm_log_usr1 (void);
|
||||
void mm_log_shutdown (void);
|
||||
|
||||
#endif /* MM_LOG_H */
|
||||
|
||||
|
Reference in New Issue
Block a user