@@ -4405,11 +4405,12 @@ gint main(int argc, char *argv[]) {
4405
4405
core_limits .rlim_cur = core_limits .rlim_max = RLIM_INFINITY ;
4406
4406
setrlimit (RLIMIT_CORE , & core_limits );
4407
4407
4408
- g_print ("Janus version: %d (%s)\n" , janus_version , janus_version_string );
4409
- g_print ("Janus commit: %s\n" , janus_build_git_sha );
4410
- g_print ("Compiled on: %s\n\n" , janus_build_git_time );
4411
4408
janus_mark_started ();
4412
4409
4410
+ JANUS_PRINT ("Janus version: %d (%s)\n" , janus_version , janus_version_string );
4411
+ JANUS_PRINT ("Janus commit: %s\n" , janus_build_git_sha );
4412
+ JANUS_PRINT ("Compiled on: %s\n\n" , janus_build_git_time );
4413
+
4413
4414
/* Initialize some command line options defaults */
4414
4415
options .debug_level = -1 ;
4415
4416
options .session_timeout = -1 ;
@@ -4443,19 +4444,19 @@ gint main(int argc, char *argv[]) {
4443
4444
}
4444
4445
if ((config = janus_config_parse (config_file )) == NULL ) {
4445
4446
/* We failed to load the libconfig configuration file, let's try the INI */
4446
- g_print ("Failed to load %s, trying the INI instead...\n" , config_file );
4447
+ JANUS_PRINT ("Failed to load %s, trying the INI instead...\n" , config_file );
4447
4448
g_free (config_file );
4448
4449
char file [255 ];
4449
4450
g_snprintf (file , 255 , "%s/janus.cfg" , configs_folder );
4450
4451
config_file = g_strdup (file );
4451
4452
if ((config = janus_config_parse (config_file )) == NULL ) {
4452
4453
if (options .config_file ) {
4453
4454
/* We only give up if the configuration file was explicitly provided */
4454
- g_print ("Error reading configuration from %s\n" , config_file );
4455
+ JANUS_PRINT ("Error reading configuration from %s\n" , config_file );
4455
4456
janus_options_destroy ();
4456
4457
exit (1 );
4457
4458
}
4458
- g_print ("Error reading/parsing the configuration file in %s, going on with the defaults and the command line arguments\n" ,
4459
+ JANUS_PRINT ("Error reading/parsing the configuration file in %s, going on with the defaults and the command line arguments\n" ,
4459
4460
configs_folder );
4460
4461
config = janus_config_create ("janus.cfg" );
4461
4462
if (config == NULL ) {
@@ -4530,18 +4531,18 @@ gint main(int argc, char *argv[]) {
4530
4531
}
4531
4532
/* Daemonize now, if we need to */
4532
4533
if (daemonize ) {
4533
- g_print ("Running Janus as a daemon\n" );
4534
+ JANUS_PRINT ("Running Janus as a daemon\n" );
4534
4535
4535
4536
/* Create a pipe for parent<->child communication during the startup phase */
4536
4537
if (pipe (pipefd ) == -1 ) {
4537
- g_print ("pipe error!\n" );
4538
+ JANUS_PRINT ("pipe error!\n" );
4538
4539
exit (1 );
4539
4540
}
4540
4541
4541
4542
/* Fork off the parent process */
4542
4543
pid_t pid = fork ();
4543
4544
if (pid < 0 ) {
4544
- g_print ("Fork error!\n" );
4545
+ JANUS_PRINT ("Fork error!\n" );
4545
4546
exit (1 );
4546
4547
}
4547
4548
if (pid > 0 ) {
@@ -4570,7 +4571,7 @@ gint main(int argc, char *argv[]) {
4570
4571
4571
4572
/* Leave the parent and return the exit code we received from the child */
4572
4573
if (code )
4573
- g_print ("Error launching Janus (error code %d), check the logs for more details\n" , code );
4574
+ JANUS_PRINT ("Error launching Janus (error code %d), check the logs for more details\n" , code );
4574
4575
exit (code );
4575
4576
}
4576
4577
/* Child here */
@@ -4582,13 +4583,13 @@ gint main(int argc, char *argv[]) {
4582
4583
/* Create a new SID for the child process */
4583
4584
pid_t sid = setsid ();
4584
4585
if (sid < 0 ) {
4585
- g_print ("Error setting SID!\n" );
4586
+ JANUS_PRINT ("Error setting SID!\n" );
4586
4587
exit (1 );
4587
4588
}
4588
4589
/* Change the current working directory */
4589
4590
const char * cwd = options .cwd_path ? options .cwd_path : "/" ;
4590
4591
if ((chdir (cwd )) < 0 ) {
4591
- g_print ("Error changing the current working directory!\n" );
4592
+ JANUS_PRINT ("Error changing the current working directory!\n" );
4592
4593
exit (1 );
4593
4594
}
4594
4595
/* We close stdin/stdout/stderr when initializing the logger */
@@ -4606,10 +4607,7 @@ gint main(int argc, char *argv[]) {
4606
4607
if (item && item -> value && janus_is_true (item -> value ))
4607
4608
exit_on_dl_error = TRUE;
4608
4609
4609
- /* Initialize logger */
4610
- if (janus_log_init (daemonize , use_stdout , logfile ) < 0 )
4611
- exit (1 );
4612
- /* Check if there are external loggers we need to load as well */
4610
+ /* Check if there are external loggers we need to load */
4613
4611
const char * path = NULL ;
4614
4612
DIR * dir = NULL ;
4615
4613
/* External loggers are usually disabled by default: they need to be enabled in the configuration */
@@ -4664,16 +4662,16 @@ gint main(int argc, char *argv[]) {
4664
4662
memset (eventpath , 0 , 1024 );
4665
4663
g_snprintf (eventpath , 1024 , "%s/%s" , path , eventent -> d_name );
4666
4664
void * event = dlopen (eventpath , RTLD_NOW | RTLD_GLOBAL );
4667
- if (!event ) {
4665
+ if (!event ) {
4668
4666
JANUS_LOG (exit_on_dl_error ? LOG_FATAL : LOG_ERR , "\tCouldn't load logger plugin '%s': %s\n" , eventent -> d_name , dlerror ());
4669
- if (exit_on_dl_error )
4667
+ if (exit_on_dl_error )
4670
4668
exit (1 );
4671
4669
} else {
4672
4670
create_l * create = (create_l * ) dlsym (event , "create" );
4673
4671
const char * dlsym_error = dlerror ();
4674
- if (dlsym_error ) {
4672
+ if (dlsym_error ) {
4675
4673
JANUS_LOG (exit_on_dl_error ? LOG_FATAL : LOG_ERR , "\tCouldn't load symbol 'create': %s\n" , dlsym_error );
4676
- if (exit_on_dl_error )
4674
+ if (exit_on_dl_error )
4677
4675
exit (1 );
4678
4676
continue ;
4679
4677
}
@@ -4717,7 +4715,10 @@ gint main(int argc, char *argv[]) {
4717
4715
if (disabled_loggers != NULL )
4718
4716
g_strfreev (disabled_loggers );
4719
4717
disabled_loggers = NULL ;
4720
- janus_log_set_loggers (loggers );
4718
+
4719
+ /* Initialize logger */
4720
+ if (janus_log_init (daemonize , use_stdout , logfile , loggers ) < 0 )
4721
+ exit (1 );
4721
4722
4722
4723
JANUS_PRINT ("---------------------------------------------------\n" );
4723
4724
JANUS_PRINT (" Starting Meetecho Janus (WebRTC Server) v%s\n" , janus_version_string );
0 commit comments