diff options
| author | Mihail Zenkov <mihail.zenkov@gmail.com> | 2016-03-31 11:33:11 +0000 |
|---|---|---|
| committer | Gerrit Rockbox <gerrit@rockbox.org> | 2016-04-04 11:07:44 +0200 |
| commit | e599810ffaa6412326f61d026fc598c721b3a01c (patch) | |
| tree | fe21a4f5f388ed87e3112f00ff68cf3448f34e4e | |
| parent | 26beb30c155aebc5e6e50366f1cfa34300a8c63a (diff) | |
| download | rockbox-e599810ffaa6412326f61d026fc598c721b3a01c.zip rockbox-e599810ffaa6412326f61d026fc598c721b3a01c.tar.gz rockbox-e599810ffaa6412326f61d026fc598c721b3a01c.tar.bz2 rockbox-e599810ffaa6412326f61d026fc598c721b3a01c.tar.xz | |
Don't add new message to logf when we dump it to file
Fix log file corruption if we have new messages at dumping log to file. Comment
removed as it incorrect. We store all messages in direct order (last message at
end of file).
Change-Id: I4acfa8a0935cc41a889e08f6bc42974fefd1ade2
| -rw-r--r-- | apps/logfdisp.c | 20 | ||||
| -rw-r--r-- | firmware/export/logf.h | 1 | ||||
| -rw-r--r-- | firmware/logf.c | 4 |
3 files changed, 16 insertions, 9 deletions
diff --git a/apps/logfdisp.c b/apps/logfdisp.c index 8547778..54c345f 100644 --- a/apps/logfdisp.c +++ b/apps/logfdisp.c @@ -218,42 +218,44 @@ 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; splashf(HZ, "Log File Dumped"); - + /* nothing to print ? */ if(logfindex == 0 && !logfwrap) /* nothing is logged just yet */ return false; - + + logfenabled = false; + fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666); if(-1 != fd) { int i; - + if(logfwrap) i = logfindex; else i = 0; - + do { if(logfbuffer[i]=='\0') fdprintf(fd, "\n"); else fdprintf(fd, "%c", logfbuffer[i]); - + i++; if(i >= MAX_LOGF_SIZE) i = 0; } while(i != logfindex); - + close(fd); } + + logfenabled = true; + return false; } diff --git a/firmware/export/logf.h b/firmware/export/logf.h index e881e7e..c8aaad0 100644 --- a/firmware/export/logf.h +++ b/firmware/export/logf.h @@ -34,6 +34,7 @@ extern unsigned char logfbuffer[MAX_LOGF_SIZE]; extern int logfindex; extern bool logfwrap; +extern bool logfenabled; #endif /* __PCTOOL__ */ #define logf _logf diff --git a/firmware/logf.c b/firmware/logf.c index 0f05c65..bdc5ad9 100644 --- a/firmware/logf.c +++ b/firmware/logf.c @@ -62,6 +62,7 @@ static int logdiskfindex; unsigned char logfbuffer[MAX_LOGF_SIZE]; int logfindex; bool logfwrap; +bool logfenabled = true; #endif #ifdef HAVE_REMOTE_LCD @@ -214,6 +215,9 @@ static int logf_push(void *userp, unsigned char c) void _logf(const char *fmt, ...) { + if (!logfenabled) + return; + #ifdef USB_ENABLE_SERIAL int old_logfindex = logfindex; #endif |