automotive-dlt
|
#include <syslog.h>
#include <limits.h>
#include <dirent.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include "dlt_offline_logstorage.h"
#include "dlt_offline_logstorage_behavior.h"
Go to the source code of this file.
app begin@ Copyright (C) 2015 Advanced Driver Information Technology. This code is developed by Advanced Driver Information Technology. Copyright of Advanced Driver Information Technology, Bosch and DENSO.
DLT offline log storage functionality source file.
For further information see http://www.genivi.org/. end@
Definition in file dlt_offline_logstorage_behavior.c.
unsigned int dlt_logstorage_get_idx_of_log_file | ( | DltLogStorageUserConfig * | file_config, |
char * | file | ||
) |
dlt_logstorage_get_idx_of_log_file
Extract index of log file name passed as input argument
file | file name to extract the index from |
file_config | User configurations for log file |
Definition at line 203 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN, DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN, DltLogStorageUserConfig::logfile_delimiter, DltLogStorageUserConfig::logfile_timestamp, and NULL.
Referenced by dlt_logstorage_open_log_file(), and dlt_logstorage_storage_dir_info().
void dlt_logstorage_log_file_name | ( | char * | log_file_name, |
DltLogStorageUserConfig * | file_config, | ||
char * | name, | ||
int | idx | ||
) |
dlt_logstorage_log_file_name
Create log file name in the form configured by the user <filename><delimiter><index><delimiter><timestamp>.dlt
filename: given in configuration file delimiter: Punctuation characters (configured in dlt.conf) timestamp: yyyy-mm-dd-hh-mm-ss (enabled/disabled in dlt.conf) index: Index len depends on wrap around value in dlt.conf ex: wrap around = 99, index will 01..99
log_file_name | contains complete logfile name |
file_config | User configurations for log file |
name | file name given in configuration file |
idx | continous index of log files @ return None |
Definition at line 53 of file dlt_offline_logstorage_behavior.c.
References DLT_MOUNT_PATH_MAX, DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN, DltLogStorageUserConfig::logfile_counteridxlen, DltLogStorageUserConfig::logfile_delimiter, DltLogStorageUserConfig::logfile_maxcounter, DltLogStorageUserConfig::logfile_timestamp, and NULL.
Referenced by dlt_logstorage_open_log_file().
int dlt_logstorage_open_log_file | ( | DltLogStorageConfigData * | config, |
DltLogStorageUserConfig * | file_config, | ||
char * | dev_path, | ||
int | msg_size | ||
) |
dlt_logstorage_open_log_file
Open a log file. Check storage directory for already created files and open the oldest if there is enough space to store at least msg_size. Otherwise create a new file, but take configured max number of files into account and remove the oldest file if needed.
config | DltLogStorageConfigData |
file_config | User configurations for log file |
dev_path | Storage device path |
msg_size | Size of incoming message |
Definition at line 371 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), dlt_logstorage_get_idx_of_log_file(), dlt_logstorage_log_file_name(), dlt_logstorage_storage_dir_info(), DLT_MOUNT_PATH_MAX, DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN, DltLogStorageConfigData::file_name, DltLogStorageConfigData::file_size, DltLogStorageConfigData::log, DltLogStorageUserConfig::logfile_maxcounter, DltLogStorageFileList::next, NULL, DltLogStorageConfigData::num_files, and DltLogStorageConfigData::records.
Referenced by dlt_logstorage_prepare_on_msg().
int dlt_logstorage_prepare_msg_cache | ( | DltLogStorageConfigData * | config, |
DltLogStorageUserConfig * | file_config, | ||
char * | dev_path, | ||
int | log_msg_size | ||
) |
dlt_logstorage_prepare_msg_cache
Prepare the log file for a certain filer. If log file not open or log files max size reached, open a new file. Create a memory area to cache data.
config | DltLogStorageConfigData |
file_config | User configurations for log file |
dev_path | Storage device path |
log_msg_size | Size of log message |
Definition at line 680 of file dlt_offline_logstorage_behavior.c.
References DltLogStorageConfigData::cache, dlt_log(), dlt_logstorage_prepare_on_msg(), DltLogStorageConfigData::file_size, g_logstorage_cache_max, g_logstorage_cache_size, DltLogStorageConfigData::log, and NULL.
Referenced by dlt_logstorage_filter_set_strategy().
int dlt_logstorage_prepare_on_msg | ( | DltLogStorageConfigData * | config, |
DltLogStorageUserConfig * | file_config, | ||
char * | dev_path, | ||
int | log_msg_size | ||
) |
dlt_logstorage_prepare_on_msg
Prepare the log file for a certain filer. If log file not open or log files max size reached, open a new file.
config | DltLogStorageConfigData |
file_config | User configurations for log file |
dev_path | Storage device path |
log_msg_size | Size of log message |
Definition at line 539 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), dlt_logstorage_open_log_file(), DltLogStorageConfigData::file_size, DltLogStorageConfigData::log, and NULL.
Referenced by dlt_logstorage_filter_set_strategy(), and dlt_logstorage_prepare_msg_cache().
void dlt_logstorage_rearrange_file_name | ( | DltLogStorageFileList ** | head | ) |
dlt_logstorage_rearrange_file_name
Rearrange the filenames in the order of latest and oldest
head | Log filename list @ return None |
Definition at line 159 of file dlt_offline_logstorage_behavior.c.
References DltLogStorageFileList::idx, DltLogStorageFileList::next, and NULL.
Referenced by dlt_logstorage_storage_dir_info().
void dlt_logstorage_sort_file_name | ( | DltLogStorageFileList ** | head | ) |
dlt_logstorage_sort_file_name
Sort the filenames with index based ascending order (bubble sort)
head | Log filename list @ return None |
Definition at line 116 of file dlt_offline_logstorage_behavior.c.
References DltLogStorageFileList::idx, DltLogStorageFileList::next, and NULL.
Referenced by dlt_logstorage_storage_dir_info().
int dlt_logstorage_storage_dir_info | ( | DltLogStorageUserConfig * | file_config, |
char * | path, | ||
DltLogStorageConfigData * | config | ||
) |
dlt_logstorage_storage_dir_info
Read file names of storage directory. Update the file list, arrange it in order of latest and oldest
file_config | User configurations for log file |
path | Path to storage directory |
config | DltLogStorageConfigData |
Definition at line 268 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), dlt_logstorage_get_idx_of_log_file(), dlt_logstorage_rearrange_file_name(), dlt_logstorage_sort_file_name(), DltLogStorageConfigData::file_name, DltLogStorageUserConfig::logfile_delimiter, DltLogStorageFileList::next, NULL, and DltLogStorageConfigData::records.
Referenced by dlt_logstorage_open_log_file().
int dlt_logstorage_sync_msg_cache | ( | DltLogStorageConfigData * | config, |
int | status | ||
) |
dlt_logstorage_sync_msg_cache
sync data to disk.
config | DltLogStorageConfigData |
status | Strategy flag |
Definition at line 825 of file dlt_offline_logstorage_behavior.c.
References DltLogStorageConfigData::cache, dlt_log(), DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT, DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET, DltLogStorageConfigData::file_size, DltLogStorageConfigData::log, NULL, and DltLogStorageConfigData::sync.
Referenced by dlt_logstorage_filter_set_strategy().
int dlt_logstorage_sync_on_msg | ( | DltLogStorageConfigData * | config, |
int | status | ||
) |
dlt_logstorage_sync_on_msg
sync data to disk.
config | DltLogStorageConfigData |
status | Strategy flag |
Definition at line 645 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), DLT_LOGSTORAGE_SYNC_ON_MSG, DltLogStorageConfigData::log, and NULL.
Referenced by dlt_logstorage_filter_set_strategy().
int dlt_logstorage_write_msg_cache | ( | DltLogStorageConfigData * | config, |
unsigned char * | data1, | ||
int | size1, | ||
unsigned char * | data2, | ||
int | size2, | ||
unsigned char * | data3, | ||
int | size3 | ||
) |
dlt_logstorage_write_msg_cache
Write the log message.
config | DltLogStorageConfigData |
data1 | header |
size1 | header size |
data2 | storage header |
size2 | storage header size |
data3 | payload |
size3 | payload size |
Definition at line 752 of file dlt_offline_logstorage_behavior.c.
References DltLogStorageConfigData::cache, dlt_log(), DltLogStorageConfigData::file_size, NULL, DltLogStorageCacheFooter::offset, and DltLogStorageCacheFooter::wrap_around_cnt.
Referenced by dlt_logstorage_filter_set_strategy().
int dlt_logstorage_write_on_msg | ( | DltLogStorageConfigData * | config, |
unsigned char * | data1, | ||
int | size1, | ||
unsigned char * | data2, | ||
int | size2, | ||
unsigned char * | data3, | ||
int | size3 | ||
) |
dlt_logstorage_write_on_msg
Write the log message.
config | DltLogStorageConfigData |
data1 | header |
size1 | header size |
data2 | storage header |
size2 | storage header size |
data3 | payload |
size3 | payload size |
Definition at line 602 of file dlt_offline_logstorage_behavior.c.
References dlt_log(), DltLogStorageConfigData::log, and NULL.
Referenced by dlt_logstorage_filter_set_strategy().