Changeset 62 in Main for trunk/Common/log.c


Ignore:
Timestamp:
Sep 19, 2024, 5:02:26 AM (2 months ago)
Author:
Nishi
Message:

add installer.sh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/log.c

    r12 r62  
    55#include "cm_string.h"
    66
     7#include <time.h>
    78#include <stdio.h>
    89#include <stdbool.h>
     
    1112#include <stdarg.h>
    1213
     14FILE* logfile;
     15
    1316bool cm_do_log = false;
    1417
    1518#define LOGNAME_LENGTH 12
     19
     20void cm_force_log(const char* log) {
     21        time_t t = time(NULL);
     22        struct tm* tm = localtime(&t);
     23        char date[513];
     24        strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm);
     25        fprintf(logfile, "[%s] %s\n", date, log);
     26        fflush(logfile);
     27}
    1628
    1729void cm_log(const char* name, const char* log, ...) {
     
    5769        }
    5870
    59         fprintf(stderr, "%s %s\n", namebuf, result);
     71        fprintf(logfile, "%s %s\n", namebuf, result);
    6072        va_end(args);
    6173
Note: See TracChangeset for help on using the changeset viewer.