30 #include <gwenhywfar/gwenhywfarapi.h>
31 #include <gwenhywfar/misc.h>
32 #include <gwenhywfar/buffer.h>
33 #include <gwenhywfar/gui.h>
68 s=getenv(
"GWEN_LOGLEVEL");
81 GWEN_LOGGER_DOMAIN *ld;
93 GWEN_LOGGER_DOMAIN *ld;
97 ld->name=strdup(name);
113 GWEN_LOGGER_DOMAIN *ld;
118 if (strcasecmp(ld->name, name)==0)
143 GWEN_LOGGER_DOMAIN *ld;
178 if (--(lg->usage)==0) {
205 fprintf(stderr,
"GWEN_Logger_SetDefaultLogger: Deprecated function\n");
229 fprintf(stderr,
"LOGGER: No filename given, will log to console.\n");
301 GWEN_LOGGER_DOMAIN *ld;
307 return ld->logger->open;
326 if (strlen(lg->logIdent)+32>=
sizeof(buffer)) {
327 fprintf(stderr,
" LOGGER: Logbuffer too small (1).\n");
336 # ifdef HAVE_SNPRINTF
338 i=snprintf(buffer,
sizeof(buffer)-1,
339 "%d:%04d/%02d/%02d %02d-%02d-%02d:%s(%d):",priority,
340 t->tm_year+1900, t->tm_mon+1, t->tm_mday,
341 t->tm_hour, t->tm_min, t->tm_sec,
342 lg->logIdent, (
int)getpid());
344 i=snprintf(buffer,
sizeof(buffer)-1,
345 "%d:%04d/%02d/%02d %02d-%02d-%02d:%s:",priority,
346 t->tm_year+1900, t->tm_mon+1, t->tm_mday,
347 t->tm_hour, t->tm_min, t->tm_sec,
350 if (i>=
sizeof(buffer)) {
351 fprintf(stderr,
" LOGGER: Logbuffer too small (2).\n");
356 sprintf(buffer,
"%d:%04d/%02d/%02d %02d-%02d-%02d:%s(%d):",priority,
357 t->tm_year+1900, t->tm_mon+1, t->tm_mday,
358 t->tm_hour, t->tm_min, t->tm_sec,
359 lg->logIdent, (
int)getpid());
361 sprintf(buffer,
"%d:%04d/%02d/%02d %02d-%02d-%02d:%s:",priority,
362 t->tm_year+1900, t->tm_mon+1, t->tm_mday,
363 t->tm_hour, t->tm_min, t->tm_sec,
368 # ifdef HAVE_SNPRINTF
369 buffer[
sizeof(buffer)-1]=0;
370 i=snprintf(buffer,
sizeof(buffer)-1,
373 if (i>=
sizeof(buffer)) {
374 fprintf(stderr,
" LOGGER: Logbuffer too small (3).\n");
378 sprintf(buffer,
"%d:%s:",priority,
414 if (priority>lg->logLevel)
419 switch(lg->logType) {
427 f=fopen(lg->logFile,
"a+");
430 "LOGGER: Unable to open file \"%s\" (%s)\n",
441 "LOGGER: Unable to write to file \"%s\" (%s)\n",
451 "LOGGER: Unable to close file \"%s\" (%s)\n",
497 if (lg->logFunction==0) {
499 "LOGGER: Logtype is \"Function\", but no function is set.\n");
546 if (priority>lg->logLevel)
554 for (i=0; i<strlen(s)+1; i++) {
631 lg->logIdent=strdup(
id);
633 lg->logIdent=strdup(
"No ident, please adjust your program");
646 lg->logFile=strdup(name);
648 lg->logFile=strdup(
"");
660 oldFn=lg->logFunction;
668 if (strcasecmp(name,
"emergency")==0)
670 else if (strcasecmp(name,
"alert")==0)
672 else if (strcasecmp(name,
"critical")==0)
674 else if (strcasecmp(name,
"error")==0)
676 else if (strcasecmp(name,
"warning")==0)
678 else if (strcasecmp(name,
"notice")==0)
680 else if (strcasecmp(name,
"info")==0)
682 else if (strcasecmp(name,
"debug")==0)
684 else if (strcasecmp(name,
"verbous")==0)
698 s=
"emergency";
break;
725 if (strcasecmp(name,
"console")==0)
727 else if (strcasecmp(name,
"file")==0)
729 else if (strcasecmp(name,
"syslog")==0)
731 else if (strcasecmp(name,
"function")==0)