Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable global prefix for log lines #1940

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/janus.jcfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ general: {
#debug_timestamps = true # Whether to show a timestamp for each log line
#debug_colors = false # Whether colors should be disabled in the log
#debug_locks = true # Whether to enable debugging of locks (very verbose!)
#log_prefix = "[janus] " # In case you want log lines to be prefixed by some
# custom text, you can use the 'log_prefix' property.
# It supports terminal colors, meaning something like
# "[\x1b[32mjanus\x1b[0m] " would show a green "janus"
# string in square brackets (assuming debug_colors=true).

# This is what you configure if you want to launch Janus as a daemon
#daemonize = true # Whether Janus should run as a daemon
Expand Down
4 changes: 3 additions & 1 deletion debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern int janus_log_level;
extern gboolean janus_log_timestamps;
extern gboolean janus_log_colors;
extern char *janus_log_global_prefix;

/** @name Janus log colors
*/
Expand Down Expand Up @@ -100,7 +101,8 @@ do { \
snprintf(janus_log_src, sizeof(janus_log_src), \
"[%s:%s:%d] ", __FILE__, __FUNCTION__, __LINE__); \
} \
JANUS_PRINT("%s%s%s" format, \
JANUS_PRINT("%s%s%s%s" format, \
janus_log_global_prefix ? janus_log_global_prefix : "", \
janus_log_ts, \
janus_log_prefix[level | ((int)janus_log_colors << 3)], \
janus_log_src, \
Expand Down
1 change: 1 addition & 0 deletions fuzzers/rtcp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Expand Down
1 change: 1 addition & 0 deletions fuzzers/rtp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

/* This is to avoid linking with openSSL */
Expand Down
1 change: 1 addition & 0 deletions fuzzers/sdp_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int janus_log_level = LOG_NONE;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;
int refcount_debug = 0;

Expand Down
1 change: 1 addition & 0 deletions janus-cfgconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
int janus_log_level = 4;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = TRUE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

/* Main Code */
Expand Down
7 changes: 7 additions & 0 deletions janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ static json_t *janus_info(const char *transaction) {
int janus_log_level = LOG_INFO;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = FALSE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;
#ifdef REFCOUNT_DEBUG
int refcount_debug = 1;
Expand Down Expand Up @@ -3810,6 +3811,11 @@ gint main(int argc, char *argv[])
janus_config_category *config_events = janus_config_get_create(config, NULL, janus_config_type_category, "events");
janus_config_category *config_loggers = janus_config_get_create(config, NULL, janus_config_type_category, "loggers");

/* Any log prefix? */
janus_config_array *lp = janus_config_get(config, config_general, janus_config_type_item, "log_prefix");
if(lp && lp->value)
janus_log_global_prefix = g_strdup(lp->value);

/* Check if there are folders to protect */
janus_config_array *pfs = janus_config_get(config, config_general, janus_config_type_array, "protected_folders");
if(pfs && pfs->list) {
Expand Down Expand Up @@ -5203,6 +5209,7 @@ gint main(int argc, char *argv[])
}
janus_mutex_unlock(&counters_mutex);
#endif
g_clear_pointer(&janus_log_global_prefix, g_free);

JANUS_PRINT("Bye!\n");

Expand Down
1 change: 1 addition & 0 deletions postprocessing/janus-pp-rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Usage: janus-pp-rec [OPTIONS] source.mjr [destination.[opus|wav|webm|mp4|srt]]
int janus_log_level = 4;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = TRUE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

gboolean janus_faststart = FALSE;
Expand Down
1 change: 1 addition & 0 deletions postprocessing/mjr2pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
int janus_log_level = 4;
gboolean janus_log_timestamps = FALSE;
gboolean janus_log_colors = TRUE;
char *janus_log_global_prefix = NULL;
int lock_debug = 0;

int working = 0;
Expand Down