- return;
-err:
- PARA_EMERG_LOG("color syntax error, arg %d (%s)\n", i,
- conf.log_color_arg[i]);
- exit(EXIT_FAILURE);
-}
-
-/**
- * Para_server's log function.
- *
- * \param ll The log level.
- * \param fmt The format string describing the log message.
- */
-__printf_2_3 void para_log(int ll, const char* fmt,...)
-{
- va_list argp;
- FILE *fp;
- struct tm *tm;
- time_t t1;
- char *color, str[MAXLINE] = "";
-
- ll = PARA_MIN(ll, NUM_LOGLEVELS - 1);
- ll = PARA_MAX(ll, LL_DEBUG);
- if (ll < conf.loglevel_arg)
- return;
-
- fp = logfile? logfile : stderr;
- color = want_colors()? log_colors[ll] : NULL;
-
- if (color)
- fprintf(fp, "%s", color);
- /* date and time */
- time(&t1);
- tm = localtime(&t1);
- strftime(str, MAXLINE, "%b %d %H:%M:%S", tm);
- fprintf(fp, "%s ", str);
- /* loglevel */
- if (conf.loglevel_arg <= LL_INFO)
- fprintf(fp, "%i: ", ll);
- if (conf.loglevel_arg <= LL_INFO) { /* log pid */
- pid_t mypid = getpid();
- fprintf(fp, "(%d) ", (int)mypid);
- }
- va_start(argp, fmt);
- vfprintf(fp, fmt, argp);
- va_end(argp);
- if (color)
- fprintf(fp, "%s", COLOR_RESET);