summaryrefslogtreecommitdiff
path: root/apps/logfdisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/logfdisp.c')
-rw-r--r--apps/logfdisp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/logfdisp.c b/apps/logfdisp.c
index 36c4997aa8..e3aa29fb76 100644
--- a/apps/logfdisp.c
+++ b/apps/logfdisp.c
@@ -19,6 +19,8 @@
19#include "config.h" 19#include "config.h"
20 20
21#ifdef ROCKBOX_HAS_LOGF 21#ifdef ROCKBOX_HAS_LOGF
22#include <file.h>
23#include <sprintf.h>
22#include <timefuncs.h> 24#include <timefuncs.h>
23#include <string.h> 25#include <string.h>
24#include <kernel.h> 26#include <kernel.h>
@@ -85,4 +87,40 @@ bool logfdisplay(void)
85} 87}
86#endif /* HAVE_LCD_BITMAP */ 88#endif /* HAVE_LCD_BITMAP */
87 89
90/* Store the logf log to logf.txt in the .rockbox directory. The order of the
91 * entries will be "reversed" so that the most recently logged entry is on the
92 * top of the file */
93bool logfdump(void)
94{
95 int fd;
96
97 if(!logfindex && !logfwrap)
98 /* nothing is logged just yet */
99 return false;
100
101 fd = open("/.rockbox/logf.txt", O_CREAT|O_WRONLY);
102 if(-1 != fd) {
103 unsigned char buffer[17];
104 int index = logfindex-1;
105 int stop = logfindex;
106
107
108 while(index != stop) {
109 if(index < 0) {
110 if(logfwrap)
111 index = MAX_LOGF_LINES-1;
112 else
113 break; /* done */
114 }
115
116 memcpy(buffer, logfbuffer[index], 16);
117 buffer[16]=0;
118 fdprintf(fd, "%s\n", buffer);
119 index--;
120 }
121 close(fd);
122 }
123 return false;
124}
125
88#endif /* ROCKBOX_HAS_LOGF */ 126#endif /* ROCKBOX_HAS_LOGF */