- va_list argp;
- FILE *outfd;
- struct tm *tm;
- time_t t1;
- char str[MAXLINE] = "";
- static char *hostname;
-
- if (ll < conf.loglevel_arg)
- return;
- if (!logfile && conf.daemon_given)
- return;
- if (!hostname)
- hostname = para_hostname();
- outfd = logfile? logfile : stderr;
- time(&t1);
- tm = localtime(&t1);
- strftime(str, MAXLINE, "%b %d %H:%M:%S", tm);
- fprintf(outfd, "%s %s ", str, hostname);
- if (conf.loglevel_arg <= LL_INFO)
- fprintf(outfd, "%i ", ll);
- va_start(argp, fmt);
- vfprintf(outfd, fmt, argp);
- va_end(argp);
+ if (conf.color_arg == color_arg_no)
+ return 0;
+ if (conf.color_arg == color_arg_yes)
+ return 1;
+ if (conf.logfile_given)
+ return 0;
+ return isatty(STDERR_FILENO);