"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log.c" between
minidlna-1.2.1.tar.gz and minidlna-1.3.0.tar.gz

About: ReadyMedia (formerly known as MiniDLNA) is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

log.c  (minidlna-1.2.1):log.c  (minidlna-1.3.0)
skipping to change at line 66 skipping to change at line 66
0 0
}; };
void void
log_close(void) log_close(void)
{ {
if (log_fp) if (log_fp)
fclose(log_fp); fclose(log_fp);
} }
int find_matching_name(const char* str, const char* names[]) { void
if (str == NULL) return -1; log_reopen(void)
{
if (log_path[0] && log_fp)
{
char logfile[1048];
snprintf(logfile, sizeof(logfile), "%s/" LOGFILE_NAME, log_path);
fclose(log_fp);
log_fp = fopen(logfile, "a");
DPRINTF(E_INFO, L_GENERAL, "Reopened log file\n");
}
}
const char* start = strpbrk(str, ",="); int find_matching_name(const char* str, const char* names[])
int level, c = (start != NULL) ? start - str : strlen(str); {
const char *start;
int level, c;
if (!str)
return -1;
start = strpbrk(str, ",=");
c = start ? start - str : strlen(str);
for (level = 0; names[level] != 0; level++) { for (level = 0; names[level] != 0; level++) {
if (!(strncasecmp(names[level], str, c))) if (!strncasecmp(names[level], str, c))
return level; return level;
} }
return -1; return -1;
} }
int int
log_init(const char *fname, const char *debug) log_init(const char *debug)
{ {
int i; int i;
FILE *fp; FILE *fp = NULL;
int level = find_matching_name(debug, level_name); int level = find_matching_name(debug, level_name);
int default_log_level = (level == -1) ? _default_log_level : level; int default_log_level = (level == -1) ? _default_log_level : level;
for (i=0; i<L_MAX; i++) for (i = 0; i < L_MAX; i++)
log_level[i] = default_log_level; log_level[i] = default_log_level;
if (debug) if (debug)
{ {
const char *rhs, *lhs, *nlhs; const char *rhs, *lhs, *nlhs;
int level, facility; int level, facility;
rhs = nlhs = debug; rhs = nlhs = debug;
while (rhs && (rhs = strchr(rhs, '='))) { while (rhs && (rhs = strchr(rhs, '='))) {
rhs++; rhs++;
skipping to change at line 120 skipping to change at line 138
DPRINTF(E_WARN, L_GENERAL, "unknown debug facility in debug string: %s", debug); DPRINTF(E_WARN, L_GENERAL, "unknown debug facility in debug string: %s", debug);
} else { } else {
log_level[facility] = level; log_level[facility] = level;
} }
lhs = strpbrk(lhs, ",="); lhs = strpbrk(lhs, ",=");
} while (*lhs && *lhs==','); } while (*lhs && *lhs==',');
} }
} }
if (!fname) // use default i.e. stdou if (log_path[0])
t {
return 0; char logfile[1048];
snprintf(logfile, sizeof(logfile), "%s/" LOGFILE_NAME, log_path);
if (!(fp = fopen(fname, "a"))) if (!(fp = fopen(logfile, "a")))
return 1; return -1;
}
log_fp = fp; log_fp = fp;
return 0; return 0;
} }
void void
log_err(int level, enum _log_facility facility, char *fname, int lineno, char *f mt, ...) log_err(int level, enum _log_facility facility, char *fname, int lineno, char *f mt, ...)
{ {
va_list ap; va_list ap;
if (level && level>log_level[facility] && level>E_FATAL) if (level && level>log_level[facility] && level>E_FATAL)
return; return;
 End of changes. 8 change blocks. 
14 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)