summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2012-07-03 21:45:29 -0400
committerMichael Giacomelli <mgiacomelli@gmail.com>2012-08-07 00:53:46 +0200
commitd46b090771291c10127d0fb421ee3c9f1e8f69b1 (patch)
treeae5a6e01f6d2025294f8905a9a791c4ede3d4869 /firmware/export
parent7c31ff2fb0cc3ba40f82c3b02daf1e7ca41e1cf6 (diff)
downloadrockbox-d46b090771291c10127d0fb421ee3c9f1e8f69b1.tar.gz
rockbox-d46b090771291c10127d0fb421ee3c9f1e8f69b1.zip
Introduce logging to disk feature into rockbox.
Logs information, errors, etc to disk using the register_storage_idle_func mechanism to write to the disk when available. Currently, this is disabled in normal builds, but can be enabled by adding ROCKBOX_HAS_LOGDISKF to the config file. By default, it uses a 2KB buffer and drops text if the buffer overflows. The system includes a simple warning level mechanism that can be used to by default exclude non-serious errors from logging on release builds. Change-Id: I0a3d186a93625c7c93dae37b993a0d37e5a3a925 Reviewed-on: http://gerrit.rockbox.org/288 Reviewed-by: Jonathan Gordon <rockbox@jdgordon.info> Tested-by: Michael Giacomelli <mgiacomelli@gmail.com> Reviewed-by: Michael Giacomelli <mgiacomelli@gmail.com>
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/logdiskf.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/firmware/export/logdiskf.h b/firmware/export/logdiskf.h
new file mode 100644
index 0000000000..628662fdba
--- /dev/null
+++ b/firmware/export/logdiskf.h
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 by Michael Giacomelli
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef LOGDISKF_H
22#define LOGDISKF_H
23#include <config.h>
24#include <stdbool.h>
25#include "gcc_extensions.h"
26#include "debug.h"
27
28#ifdef ROCKBOX_HAS_LOGDISKF
29
30void init_logdiskf(void);
31
32#ifndef __PCTOOL__
33
34/*large memory devices spin up the disk much less often*/
35#if MEMORYSIZE > 32
36 #define MAX_LOGDISKF_SIZE 8192
37#elif MEMORYSIZE > 8
38 #define MAX_LOGDISKF_SIZE 4096
39#else
40 #define MAX_LOGDISKF_SIZE 1024
41#endif
42
43extern unsigned char logdiskfbuffer[MAX_LOGDISKF_SIZE];
44extern int logfdiskindex;
45#endif /* __PCTOOL__ */
46
47
48#define LOGDISK_LEVEL 1
49
50#if LOGDISK_LEVEL > 0 /*serious errors or problems*/
51 #define ERRORF(...) _logdiskf(__func__,'E', __VA_ARGS__)
52#else
53 #define ERRORF(...)
54#endif
55
56#if LOGDISK_LEVEL > 1 /*matters of concern*/
57 #define WARNF(...) _logdiskf(__func__, 'W', __VA_ARGS__)
58#else
59 #define WARNF(...)
60#endif
61
62#if LOGDISK_LEVEL > 2 /*useful for debug only*/
63 #define NOTEF(...) _logdiskf(__func__, 'N', __VA_ARGS__)
64#else
65 #define NOTEF(...) /*TODO: rename DEBUGF later*/
66#endif
67
68/*__FILE__ would be better but is difficult to make work with the build system*/
69//#define logdiskf(...) _logdiskf(__func__, 1, __VA_ARGS__)
70
71void _logdiskf(const char* file, const char level,
72 const char *format, ...) ATTRIBUTE_PRINTF(3, 4);
73
74#else /* !ROCKBOX_HAS_LOGF */
75
76/* built without logdiskf() support enabled, replace logdiskf() by DEBUGF() */
77#define logdiskf(f,args...) DEBUGF(f"\n",##args)
78
79#endif /* !ROCKBOX_HAS_LOGDISKF */
80
81#endif /* LOGDISKF_H */