summaryrefslogtreecommitdiff
path: root/src/offlinelogstorage/dlt_offline_logstorage.h
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2015-10-26 14:57:00 +0900
committerLutz Helwing <lutz_helwing@mentor.com>2015-11-24 09:48:42 +0100
commitd73717a4f6b243d40388bb1d3bb9db7421d7b9b0 (patch)
tree091f25b5f38257f611733e4757b762a036b12d83 /src/offlinelogstorage/dlt_offline_logstorage.h
parent5574d46a4083d783a915688e0e05593b9558497b (diff)
downloadDLT-daemon-d73717a4f6b243d40388bb1d3bb9db7421d7b9b0.tar.gz
DltLogstorage: Logstorage Cache
When using DltLogstorage on internal storage device, it is needed to reduce writing to internal storage device as much as possible. This patch introduces sync strategies to Logstorage to provide that functionality. The ON_MSG strategy is the default sync strategy that flushes every written log message to the storage device (fflush). The ON_DAEMON_EXIT strategy only flushes data to disk when the daemon exits. The strategy can be defined per filter in the dlt_logstorage.conf configuration file by adding SyncBehavior=<Strategy> to a configuration. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Diffstat (limited to 'src/offlinelogstorage/dlt_offline_logstorage.h')
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage.h57
1 files changed, 47 insertions, 10 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.h b/src/offlinelogstorage/dlt_offline_logstorage.h
index 80a75e8..01427a1 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.h
+++ b/src/offlinelogstorage/dlt_offline_logstorage.h
@@ -81,16 +81,18 @@
DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + 1)
#define DLT_OFFLINE_LOGSTORAGE_FILTER_UNINIT 0
-#define DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT (1<<6)
-#define DLT_OFFLINE_LOGSTORAGE_APP_INIT (1<<5)
-#define DLT_OFFLINE_LOGSTORAGE_CTX_INIT (1<<4)
-#define DLT_OFFLINE_LOGSTORAGE_LOG_LVL_INIT (1<<3)
-#define DLT_OFFLINE_LOGSTORAGE_NAME_INIT (1<<2)
-#define DLT_OFFLINE_LOGSTORAGE_SIZE_INIT (1<<1)
+#define DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT (1<<7)
+#define DLT_OFFLINE_LOGSTORAGE_APP_INIT (1<<6)
+#define DLT_OFFLINE_LOGSTORAGE_CTX_INIT (1<<5)
+#define DLT_OFFLINE_LOGSTORAGE_LOG_LVL_INIT (1<<4)
+#define DLT_OFFLINE_LOGSTORAGE_NAME_INIT (1<<3)
+#define DLT_OFFLINE_LOGSTORAGE_SIZE_INIT (1<<2)
+#define DLT_OFFLINE_LOGSTORAGE_SYNC_BEHAVIOR (1<<1)
#define DLT_OFFLINE_LOGSTORAGE_NUM_INIT 1
-#define DLT_OFFLINE_LOGSTORAGE_FILTER_INIT 0x7F
+/* Sync behavior is optional */
+#define DLT_OFFLINE_LOGSTORAGE_FILTER_INIT 0xFD
-#define DLT_OFFLINE_LOGSTORAGE_FILTER_INITIALIZED(A) ((A) == DLT_OFFLINE_LOGSTORAGE_FILTER_INIT)
+#define DLT_OFFLINE_LOGSTORAGE_FILTER_INITIALIZED(A) ((A) >= DLT_OFFLINE_LOGSTORAGE_FILTER_INIT)
#define DLT_OFFLINE_LOGSTORAGE_IS_FILTER_PRESENT(A) ((A) & DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT)
@@ -105,10 +107,26 @@
#define DLT_OFFLINE_LOGSTORAGE_MIN(A, B) ((A) < (B) ? (A) : (B))
#define DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS 5
-#define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_NUM 6
+#define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_NUM 7
#define DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION "FILTER"
+/* Offline Logstorage sync strategies */
+#define DLT_LOGSTORAGE_SYNC_ON_MSG 0x00 /* default, on message sync */
+#define DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT 0x01 /* sync on daemon exit */
+
+
+/* logstorage max cache */
+unsigned int g_logstorage_cache_max;
+/* current logstorage cache size */
+unsigned int g_logstorage_cache_size;
+
+typedef struct
+{
+ int offset; /* current write offset */
+ unsigned int wrap_around_cnt; /* wrap around counter */
+}DltLogStorageCacheFooter;
+
typedef struct
{
/* File name user configurations */
@@ -126,14 +144,33 @@ typedef struct DltLogStorageFileList
struct DltLogStorageFileList *next;
}DltLogStorageFileList;
-typedef struct
+typedef struct DltLogStorageConfigData DltLogStorageConfigData;
+
+typedef struct DltLogStorageConfigData
{
/* filter section */
int log_level; /* Log level number configured for filter */
char *file_name; /* File name for log storage configured for filter */
unsigned int file_size; /* MAX File size of storage file configured for filter */
unsigned int num_files; /* MAX number of storage files configured for filters */
+ int sync; /* Sync strategy */
+ /* callback function for filter configurations */
+ int (*dlt_logstorage_prepare)(DltLogStorageConfigData *config,
+ DltLogStorageUserConfig *file_config,
+ char *dev_path,
+ int log_msg_size);
+ int (*dlt_logstorage_write)(DltLogStorageConfigData *config,
+ unsigned char *data1,
+ int size1,
+ unsigned char *data2,
+ int size2,
+ unsigned char *data3,
+ int size3);
+ /* status is strategy, e.g. DLT_LOGSTORAGE_SYNC_ON_MSG is used when callback
+ * is called on message received */
+ int (*dlt_logstorage_sync)(DltLogStorageConfigData *config, int status);
FILE *log; /* current open log file */
+ void *cache; /* log data cache */
DltLogStorageFileList *records; /* File name list */
}DltLogStorageConfigData;