functions.c 558 B

123456789101112131415161718192021222324
  1. /// MicroIRCd
  2. #include "deps.h"
  3. #include "server.h"
  4. #include "functions.h"
  5. void _log(char *fmt, ...)
  6. {
  7. int i;
  8. char buf[BUF_SIZE];
  9. char timestr[32];
  10. time_t t = time(0);
  11. va_list ap;
  12. va_start(ap, fmt);
  13. vsnprintf(buf, BUF_SIZE - 1, fmt, ap);
  14. va_end(ap);
  15. for (i = 0; i < (int)strlen(buf) - 1; i++)
  16. buf[i] = (unsigned char)buf[i] < 32 ? '.' : buf[i];
  17. strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S ", localtime(&t));
  18. fprintf(stdout, "%s", timestr);
  19. fprintf(stdout, "%s", buf);
  20. fflush(stdout);
  21. }