]>
Commit | Line | Data |
---|---|---|
7fe9b0b7 | 1 | #include <stdarg.h> |
2 | #include <stdio.h> | |
3 | #include <time.h> | |
4 | ||
5 | #include "ui.h" | |
6 | ||
7 | double CursorScaleFactor; | |
8 | int PlotGridX, PlotGridY; | |
9 | int offline; | |
10 | ||
11 | static char *logfilename = "proxmark3.log"; | |
12 | ||
13 | void PrintAndLog(char *fmt, ...) | |
14 | { | |
15 | va_list argptr, argptr2; | |
16 | static FILE *logfile = NULL; | |
17 | static int logging=1; | |
18 | ||
19 | if (logging && !logfile) { | |
20 | logfile=fopen(logfilename, "a"); | |
21 | if (!logfile) { | |
22 | fprintf(stderr, "Can't open logfile, logging disabled!\n"); | |
23 | logging=0; | |
24 | } | |
25 | } | |
26 | ||
27 | va_start(argptr, fmt); | |
28 | va_copy(argptr2, argptr); | |
29 | vprintf(fmt, argptr); | |
30 | va_end(argptr); | |
31 | printf("\n"); | |
32 | if (logging && logfile) { | |
33 | #if 0 | |
34 | char zeit[25]; | |
35 | time_t jetzt_t; | |
36 | struct tm *jetzt; | |
37 | ||
38 | jetzt_t = time(NULL); | |
39 | jetzt = localtime(&jetzt_t); | |
40 | strftime(zeit, 25, "%b %e %T", jetzt); | |
41 | ||
42 | fprintf(logfile,"%s ", zeit); | |
43 | #endif | |
44 | vfprintf(logfile, fmt, argptr2); | |
45 | fprintf(logfile,"\n"); | |
46 | fflush(logfile); | |
47 | } | |
48 | va_end(argptr2); | |
49 | } | |
50 | ||
51 | void SetLogFilename(char *fn) | |
52 | { | |
53 | logfilename = fn; | |
54 | } |