]>
Commit | Line | Data |
---|---|---|
6658905f | 1 | #include <stdarg.h> |
2 | #include <stdio.h> | |
3 | #include <time.h> | |
4 | ||
5 | #include "proxgui.h" | |
6 | #include "translate.h" | |
7 | #include "../winsrc/prox.h" | |
8 | ||
9 | int GraphBuffer[MAX_GRAPH_TRACE_LEN]; | |
10 | int GraphTraceLen; | |
11 | double CursorScaleFactor; | |
12 | int CommandFinished; | |
13 | ||
14 | static char *logfilename = "proxmark3.log"; | |
15 | ||
16 | void PrintToScrollback(char *fmt, ...) { | |
17 | va_list argptr; | |
18 | static FILE *logfile = NULL; | |
19 | static int logging=1; | |
20 | ||
21 | if (logging && !logfile) { | |
22 | logfile=fopen(logfilename, "a"); | |
23 | if (!logfile) { | |
24 | fprintf(stderr, "Can't open logfile, logging disabled!\n"); | |
25 | logging=0; | |
26 | } | |
27 | } | |
28 | ||
29 | va_start(argptr, fmt); | |
30 | vprintf(fmt, 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, argptr); | |
45 | fprintf(logfile,"\n"); | |
46 | fflush(logfile); | |
47 | } | |
48 | va_end(argptr); | |
49 | } | |
50 | ||
51 | void setlogfilename(char *fn) | |
52 | { | |
53 | logfilename = fn; | |
54 | } |