MCPcopy Create free account
hub / github.com/3proxy/3proxy / h_log

Function h_log

src/conf.c:287–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287static int h_log(int argc, unsigned char ** argv){
288 unsigned char tmpbuf[8192];
289 conf.logfunc = logstdout;
290 if(conf.logtarget){
291 myfree(conf.logtarget);
292 conf.logtarget = NULL;
293 }
294 if(argc > 1) {
295 conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
296 if(*argv[1]=='@'){
297#ifndef _WIN32
298 openlog((char *)conf.logtarget+1, LOG_PID, LOG_DAEMON);
299 conf.logfunc = logsyslog;
300#endif
301 }
302#ifndef NOODBC
303 else if(*argv[1]=='&'){
304 pthread_mutex_lock(&log_mutex);
305 close_sql();
306 init_sql((char *)argv[1]+1);
307 pthread_mutex_unlock(&log_mutex);
308 conf.logfunc = logsql;
309 }
310#endif
311 else {
312 FILE *fp;
313 if(argc > 2) {
314 conf.logtype = getrotate(*argv[2]);
315 }
316 conf.logtime = time(0);
317 if(conf.logname)myfree(conf.logname);
318 conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
319 fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
320 if(!fp){
321 perror((char *)tmpbuf);
322 return 1;
323 }
324 else {
325 if(conf.stdlog)fclose(conf.stdlog);
326 conf.stdlog = fp;
327#ifdef _WINCE
328 freopen(tmpbuf, "w", stdout);
329 freopen(tmpbuf, "w", stderr);
330#endif
331 }
332 }
333 }
334 return 0;
335}
336
337static int h_stacksize(int argc, unsigned char **argv){
338 conf.stacksize = atoi((char *)argv[1]);

Callers

nothing calls this directly

Calls 4

myfreeFunction · 0.85
mystrdupFunction · 0.85
getrotateFunction · 0.85
dolognameFunction · 0.85

Tested by

no test coverage detected