summarylogtreecommitdiffstats
path: root/lwarnlib.c
blob: edea2aa87f9cd973eada0128420b6bf45a5581c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "lwarnlib.h"

#include <stdio.h>
#include <time.h>

/* get HH:MM:SS only */
void warn_time(char *buf, size_t len) {
    time_t now = time(NULL);
    struct tm *t = localtime(&now);

    strftime(buf, len, "%H:%M:%S", t);
}

/* framebuffer warning */
void fbwarn(const char *msg) {
    char ts[16];
    warn_time(ts, sizeof(ts));

    fprintf(stderr,
        "[ WARN ] %s: framebuffer (fb0) %s\n",
        ts,
        msg
    );
}