Changeset 3499
- Timestamp:
- 10/13/10 10:31:40 (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r3487 r3499 1285 1285 extern void init_ac(void); 1286 1286 extern void ac_init_stat(); 1287 extern int ac_init_log( char*);1287 extern int ac_init_log(); 1288 1288 extern void ac_do_stat(void); 1289 1289 extern void ac_init_client(struct s_auth *); … … 1369 1369 1370 1370 // oscam-log 1371 extern int cs_init_log( char *);1371 extern int cs_init_log(); 1372 1372 extern void cs_write_log(char *); 1373 1373 extern void cs_log(const char *,...); … … 1386 1386 #endif 1387 1387 extern void cs_close_log(void); 1388 extern int cs_init_statistics( char *);1388 extern int cs_init_statistics(); 1389 1389 extern void cs_dump(const uchar *, int, char *, ...); 1390 1390 -
trunk/oscam-ac.c
r3473 r3499 8 8 struct s_acasc ac_stat[CS_MAXPID]; 9 9 10 int ac_init_log( char *file)10 int ac_init_log(void) 11 11 { 12 if( (!fpa) && (file[0])) 12 13 if( (!fpa) && (cfg->ac_logfile[0])) 13 14 { 14 if( (fpa=fopen( file, "a+"))<=(FILE *)0 )15 if( (fpa=fopen(cfg->ac_logfile, "a+"))<=(FILE *)0 ) 15 16 { 16 17 fpa=(FILE *)0; 17 fprintf(stderr, "can't open anti-cascading logfile: %s\n", file);18 fprintf(stderr, "can't open anti-cascading logfile: %s\n", cfg->ac_logfile); 18 19 } 19 20 else … … 32 33 fclose(fpa); 33 34 fpa=(FILE *)0; 34 if( ac_init_log( cfg->ac_logfile) )35 if( ac_init_log() ) 35 36 cs_exit(0); 36 37 } -
trunk/oscam-config.c
r3483 r3499 1500 1500 #endif 1501 1501 cs_init_statistics(cfg->usrfile); 1502 cs_init_log( cfg->logfile);1502 cs_init_log(); 1503 1503 if (cfg->ftimeout >= cfg->ctimeout) { 1504 1504 cfg->ftimeout = cfg->ctimeout - 100; -
trunk/oscam-log.c
r3496 r3499 8 8 static FILE *fp=(FILE *)0; 9 9 static FILE *fps=(FILE *)0; 10 static int use_syslog=0;11 static int use_stdout=0;12 10 13 11 #ifdef CS_ANTICASC … … 15 13 #endif 16 14 17 static void switch_log(char* file, FILE **f, int (*pfinit)(char*)) 18 { 19 if( cfg->max_log_size ) 15 static void switch_log(char* file, FILE **f, int (*pfinit)(void)) 16 { 17 if( cfg->max_log_size) //only 1 thread needs to switch the log; even if anticasc, statistics and normal log are running 18 //at the same time, it is ok to have the other logs switching 1 entry later 20 19 { 21 20 struct stat stlog; 21 22 22 if( stat(file, &stlog)!=0 ) 23 23 { … … 39 39 file, prev_log, errno); 40 40 } 41 else if( pfinit(file)) 42 cs_exit(0); 41 else 42 if( pfinit()) 43 fprintf(stderr, "Initialisation of log file failed, continuing without logging thread %08lX.", pthread_self()); 43 44 } 44 45 } … … 63 64 } 64 65 } else { 65 i f (fp || use_stdout) {66 if( !use_stdout && !use_syslog)66 int use_stdout = (strcmp(cfg->logfile, "stdout"))?0:1; 67 if (fp && !use_stdout && strcmp(cfg->logfile, "syslog")) 67 68 switch_log(cfg->logfile, &fp, cs_init_log); 68 if (!cfg->disablelog){69 if ((fp || use_stdout) && (!cfg->disablelog)){ 69 70 fprintf(fp, "%s", txt); 70 71 fflush(fp); 71 }72 72 } 73 73 } 74 74 } 75 75 76 int cs_init_log( char *file)76 int cs_init_log(void) 77 77 { 78 78 static char *head = ">> OSCam << cardserver started version " CS_VERSION ", build #" CS_SVN_VERSION " (" CS_OSTYPE ")"; 79 79 80 if (!strcmp(file, "stdout")) { 81 use_stdout = 1; 80 if (!strcmp(cfg->logfile, "stdout")) {//log to stdout 82 81 fp = stdout; 83 82 cs_log(head); … … 85 84 return(0); 86 85 } 87 if (strcmp( file, "syslog")) {86 if (strcmp(cfg->logfile, "syslog")) {//log to file 88 87 if (!fp) { 89 if ((fp = fopen( file, "a+")) <= (FILE *)0) {88 if ((fp = fopen(cfg->logfile, "a+")) <= (FILE *)0) { 90 89 fp = (FILE *)0; 91 fprintf(stderr, "couldn't open logfile: %s (errno %d)\n", file, errno);90 fprintf(stderr, "couldn't open logfile: %s (errno %d)\n", cfg->logfile, errno); 92 91 } else { 93 92 time_t t; … … 102 101 } 103 102 return(fp <= (FILE *)0); 104 } else { 103 } else { //log to syslog 105 104 openlog("oscam", LOG_NDELAY, LOG_DAEMON); 106 use_syslog = 1;107 105 cs_log(head); 108 106 cs_log_config(); … … 143 141 144 142 #ifdef CS_ANTICASC 145 if ( use_syslog&& cur_client()->typ != 'a') // system-logfile143 if ((!strcmp(cfg->logfile, "syslog")) && cur_client()->typ != 'a') // system-logfile 146 144 #else 147 if ( use_syslog) // system-logfile145 if (!strcmp(cfg->logfile, "syslog")) // system-logfile 148 146 #endif 149 147 syslog(LOG_INFO, "%s", txt); … … 206 204 void cs_close_log(void) 207 205 { 208 if ( use_stdout || use_syslog|| !fp) return;206 if (!strcmp(cfg->logfile, "stdout") || (!strcmp(cfg->logfile, "syslog")) || !fp) return; 209 207 fclose(fp); 210 208 fp=(FILE *)0; … … 338 336 } 339 337 #endif 340 int cs_init_statistics( char *file)341 { 342 if ((!fps) && ( file != NULL))343 { 344 if ((fps=fopen( file, "a+"))<=(FILE *)0)338 int cs_init_statistics(void) 339 { 340 if ((!fps) && (cfg->usrfile != NULL)) 341 { 342 if ((fps=fopen(cfg->usrfile, "a+"))<=(FILE *)0) 345 343 { 346 344 fps=(FILE *)0; 347 cs_log("couldn't open statistics file: %s", file);345 cs_log("couldn't open statistics file: %s", cfg->usrfile); 348 346 } 349 347 }
Note:
See TracChangeset
for help on using the changeset viewer.