Added human-readable compilation date in usage output.

Remove verbatim unix timestamp compilation date in usage output on release builds.

Fortune for naka's current commit: Blessing − 吉
master
Avril 3 years ago
parent 4b6cc7034b
commit 033ec9e902
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -2,6 +2,7 @@
#ifndef _PROJECT_H
#define _PROJECT_H
#include <time.h>
#include <limits.h>
#include "macros.h"
@ -24,7 +25,7 @@
/// Project license
#define PROG_LICENSE _PROJECT_LICENSE
/// Compiled time (UTC unix timestamp)
#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, u64)
#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, time_t)
// Returns from the program

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <ints.h>
#include <macros.h>
@ -15,6 +16,21 @@
#include <map.h>
#include <comp.h>
static const char* _compdate_readable()
{
static const time_t comp = PROG_COMPILED_TIMESTAMP;
static _Thread_local char date[40] = {0};
debug_assert(sizeof(date) == 40);
struct tm* time = gmtime(&comp);
if(!date[0]) {
usize w = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", time);
TRACE("size of hr time: %lu / %lu", w, sizeof(date));
}
return date;
}
static void pi_print_trace_infos(FILE* out)
{
const char* name;
@ -42,10 +58,19 @@ void prog_info(FILE* out)
#ifdef DEBUG
" (debug build)"
#endif
"\n written by %s with <3 (compiled at %lu UTC (unix ts))\n license %s.\n",
"\n written by %s with <3 (compiled at %s UTC."
#ifdef DEBUG
" %lu uts)"
#else
")"
#endif
"\n license %s.\n",
v_ctoss(v_rawtoc(PROG_VERSION)),
PROG_AUTHOUR,
_compdate_readable(),
#ifdef DEBUG
PROG_COMPILED_TIMESTAMP,
#endif
PROG_LICENSE);
fprintf(out, "\nLogging levels: (set with env-var `%s')\n", _TRACE_CONTROL_ENV_NAME);
pi_print_trace_infos(out);

Loading…
Cancel
Save