Added logfdump - that writes the internal logf log to .rockbox/logf.txt

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6545 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2005-06-01 13:07:37 +00:00
parent e6910760b1
commit c95319f6fd
4 changed files with 41 additions and 0 deletions

View file

@ -2050,6 +2050,7 @@ bool debug_menu(void)
#endif
#ifdef ROCKBOX_HAS_LOGF
{"logf", logfdisplay },
{"logfdump", logfdump },
#endif
};

View file

@ -19,6 +19,8 @@
#include "config.h"
#ifdef ROCKBOX_HAS_LOGF
#include <file.h>
#include <sprintf.h>
#include <timefuncs.h>
#include <string.h>
#include <kernel.h>
@ -85,4 +87,40 @@ bool logfdisplay(void)
}
#endif /* HAVE_LCD_BITMAP */
/* Store the logf log to logf.txt in the .rockbox directory. The order of the
* entries will be "reversed" so that the most recently logged entry is on the
* top of the file */
bool logfdump(void)
{
int fd;
if(!logfindex && !logfwrap)
/* nothing is logged just yet */
return false;
fd = open("/.rockbox/logf.txt", O_CREAT|O_WRONLY);
if(-1 != fd) {
unsigned char buffer[17];
int index = logfindex-1;
int stop = logfindex;
while(index != stop) {
if(index < 0) {
if(logfwrap)
index = MAX_LOGF_LINES-1;
else
break; /* done */
}
memcpy(buffer, logfbuffer[index], 16);
buffer[16]=0;
fdprintf(fd, "%s\n", buffer);
index--;
}
close(fd);
}
return false;
}
#endif /* ROCKBOX_HAS_LOGF */

View file

@ -19,6 +19,7 @@
#ifndef LOGFDISP_H
#define LOGFDISP_H
bool logfdisplay(void);
bool logfdump(void);
#endif /* LOGFDISP_H */

View file

@ -351,6 +351,7 @@ bool info_menu(void)
{ ID2P(LANG_USB), simulate_usb },
#ifdef ROCKBOX_HAS_LOGF
{"logf", logfdisplay },
{"logfdump", logfdump },
#endif
#endif
};