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