56 static void (*
hook_func)(int,
const char *,
void *) = NULL;
61 #define TIMEFORMAT_LEN 50
75 #define MAX_MASK_NAMES 35
104 static int mutex_init_flag = 0;
111 env = getenv(
"YAZ_LOG");
168 for (i = 0; i<9; i++)
170 char fname_str[FILENAME_MAX];
171 struct stat stat_buf;
173 yaz_snprintf(fname_str,
sizeof(fname_str),
"%s.%d", cur_fname, i);
174 if (stat(fname_str, &stat_buf) != 0)
179 char fname_str[2][FILENAME_MAX];
183 "%s.%d", cur_fname, i-1);
188 "%s.%d", cur_fname, i);
190 MoveFileEx(fname_str[0], fname_str[1], MOVEFILE_REPLACE_EXISTING);
192 rename(fname_str[0], fname_str[1]);
211 const char *bittype =
"Static ";
214 yaz_log(YLOG_LOGLVL,
"Setting log level to %d = 0x%08x",
220 for (i = 0; i < sz; i++)
224 yaz_log(YLOG_LOGLVL,
"%s log bit %08x '%s' is %s",
235 if (prefix && *prefix)
244 if (prefix && *prefix)
288 char new_filename[512];
289 static char cur_filename[512] =
"";
296 strftime(new_filename,
sizeof(new_filename)-1,
yaz_log_info.l_fname,
298 if (strcmp(new_filename, cur_filename))
300 strcpy(cur_filename, new_filename);
314 if (force && *cur_filename)
320 new_file = fopen(cur_filename, filemode);
338 time_t cur_time = time(0);
340 struct tm tm0, *tm = &tm0;
346 localtime_r(&cur_time, tm);
348 tm = localtime(&cur_time);
365 const char *fmt,
const struct tm *tm)
367 strftime(dst, sz, fmt, tm);
375 struct tm tm0, *tm = &tm0;
383 localtime_r(&ti, tm);
433 fprintf(file,
"%s%s%s%s %s%s\n", tbuf,
yaz_log_info.l_prefix,
455 if (strlen(buf) >=
sizeof(buf)-31)
456 strcat(buf,
" [rest of output omitted]");
460 size_t remain =
sizeof(buf) - strlen(buf);
487 if (0==strcmp(fmt,
"old"))
499 static char *
clean_name(
const char *
name,
size_t len,
char *namebuf,
size_t buflen)
502 char *start = namebuf;
505 strncpy(namebuf, name, len);
507 while ((p = strchr(start,
'/')))
509 if ((p = strrchr(start,
'.')))
530 mask_names[i].name = (
char *) malloc(strlen(name)+1);
541 char *n =
clean_name(name, strlen(name), clean,
sizeof(clean));
549 strcmp(n,name) ? name :
"");
553 strcmp(n, name) ? name :
"" );
571 for (p = str; *p && *p !=
','; p++)
585 char *n =
clean_name(str, (
size_t) (p - str), clean,
sizeof(clean));