Changeset 4554 for trunk/oscam-log.c
- Timestamp:
- 01/21/11 00:56:01 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-log.c
r4551 r4554 5 5 static FILE *fp=(FILE *)0; 6 6 static FILE *fps=(FILE *)0; 7 static short logStarted = 0; 7 8 8 9 pthread_mutex_t switching_log; … … 78 79 if(!cfg->disablelog){ 79 80 if (fp){ 80 switch_log(cfg->logfile, &fp, cs_ init_log);81 switch_log(cfg->logfile, &fp, cs_open_logfiles); 81 82 if (fp) { 82 83 fputs(txt, fp); … … 86 87 if(cfg->logtostdout){ 87 88 fputs(txt, stdout); 88 fflush(fp); 89 } 90 } 91 } 92 } 93 94 int cs_init_log(void) 95 { 96 static char *head = ">> OSCam << cardserver started version " CS_VERSION ", build #" CS_SVN_VERSION " (" CS_OSTYPE ")"; 97 98 pthread_mutex_init(&switching_log, NULL); 99 #ifdef CS_LOGHISTORY 100 pthread_mutex_init(&loghistory_lock, NULL); 101 #endif 102 89 fflush(stdout); 90 } 91 } 92 } 93 } 94 95 int cs_open_logfiles() 96 { 103 97 if (!fp) { //log to file 104 98 if ((fp = fopen(cfg->logfile, "a+")) <= (FILE *)0) { … … 116 110 } 117 111 if (cfg->logtosyslog) { //log to syslog 112 if(logStarted == 1) closelog(); 118 113 openlog("oscam", LOG_NDELAY, LOG_DAEMON); 119 114 } 120 cs_log( head);115 cs_log(">> OSCam << cardserver started version " CS_VERSION ", build #" CS_SVN_VERSION " (" CS_OSTYPE ")"); 121 116 cs_log_config(); 122 117 return(fp <= (FILE *)0); 118 } 119 120 int cs_init_log(void) 121 { 122 if(logStarted == 0){ 123 pthread_mutex_init(&switching_log, NULL); 124 #ifdef CS_LOGHISTORY 125 pthread_mutex_init(&loghistory_lock, NULL); 126 #endif 127 } 128 int rc = cs_open_logfiles(); 129 logStarted = 1; 130 return rc; 123 131 } 124 132
Note:
See TracChangeset
for help on using the changeset viewer.