Project

General

Profile

Statistics
| Branch: | Revision:

root / mainbox / log.c @ 5e03b78d

History | View | Annotate | Download (473 Bytes)

1
#include "log.h"
2
#include <stdio.h>
3
#include <stdarg.h>
4
#include <time.h>
5
#include <errno.h>
6
#include <sys/time.h>
7

    
8
void log_time() {
9
  char buf[100];
10
  time_t t;
11
  time(&t);
12
  strftime(buf, sizeof(buf), "%b %e %T %Y", localtime(&t));
13
  printf("[%s] ", buf);
14
}
15

    
16
void log_print(const char *fmt, ...) {
17
  va_list args;
18
  va_start(args, fmt);
19
  log_time();
20
  vprintf(fmt, args);
21
  printf("\n");
22
  va_end(args);
23
}
24

    
25
void log_perror(const char *s) {
26
  log_time();
27
  perror(s);
28
}