automotive-dlt
dlt_daemon_offline_logstorage.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "dlt_daemon_offline_logstorage.h"
Include dependency graph for dlt_daemon_offline_logstorage.c:

Go to the source code of this file.

Functions

int dlt_logstorage_split_key (char *key, char *appid, char *ctxid)
 
int dlt_logstorage_update_all_contexts (DltDaemon *daemon, char *id, int curr_log_level, int cmp_flag, int verbose)
 
int dlt_logstorage_update_context (DltDaemon *daemon, char *apid, char *ctxid, int curr_log_level, int verbose)
 
int dlt_logstorage_update_context_loglevel (DltDaemon *daemon, char *key, int curr_log_level, int verbose)
 
void dlt_daemon_logstorage_reset_application_loglevel (DltDaemon *daemon, int dev_num, int max_device, int verbose)
 
void dlt_daemon_logstorage_update_application_loglevel (DltDaemon *daemon, int dev_num, int verbose)
 
int dlt_daemon_logstorage_get_loglevel (DltDaemon *daemon, int max_device, char *apid, char *ctid)
 
void dlt_daemon_logstorage_write (DltDaemon *daemon, DltDaemonFlags *user_config, unsigned char *data1, int size1, unsigned char *data2, int size2, unsigned char *data3, int size3)
 
int dlt_daemon_logstorage_setup_internal_storage (DltDaemon *daemon, char *path, int verbose)
 
void dlt_daemon_logstorage_set_logstorage_cache_size (unsigned int size)
 
int dlt_daemon_logstorage_cleanup (DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
 
int dlt_daemon_logstorage_sync_cache (DltDaemon *daemon, DltDaemonLocal *daemon_local, char *mnt_point, int verbose)
 
DltLogStoragedlt_daemon_logstorage_get_device (DltDaemon *daemon, DltDaemonLocal *daemon_local, char *mnt_point, int verbose)
 

Detailed Description

app begin@ Copyright (C) 2013 - 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.

Author
Syed Hameed shame.nosp@m.ed@j.nosp@m.p.adi.nosp@m.t-jv.nosp@m..com ADIT 2013 - 2015
Christoph Lipka clipk.nosp@m.a@jp.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015

For further information see http://www.genivi.org/. end@

Definition in file dlt_daemon_offline_logstorage.c.

Function Documentation

int dlt_daemon_logstorage_cleanup ( DltDaemon daemon,
DltDaemonLocal daemon_local,
int  verbose 
)

Cleanup dlt logstorage

Parameters
daemonPointer to Dlt Daemon structure
daemon_localPointer to Dlt Daemon Local structure
verboseIf set to true verbose information is printed out

Definition at line 579 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::connection_type, dlt_logstorage_device_disconnected(), DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DltDaemonLocal::flags, NULL, DltDaemonFlags::offlineLogstorageMaxDevices, PRINT_FUNCTION_VERBOSE, and DltDaemon::storage_handle.

Referenced by dlt_daemon_local_cleanup().

DltLogStorage* dlt_daemon_logstorage_get_device ( DltDaemon daemon,
DltDaemonLocal daemon_local,
char *  mnt_point,
int  verbose 
)

dlt_logstorage_get_device

Get a Logstorage device handle for given the mount point.

Parameters
daemonPointer to Dlt Daemon structure
daemon_localPointer to Dlt Daemon Local structure
mount_pointLogstorage device mount point
verboseIf set to true verbose information is printed out
Returns
handle to Logstorage device on success, NULL otherwise

Definition at line 658 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::device_mount_point, DltDaemonLocal::flags, NULL, DltDaemonFlags::offlineLogstorageMaxDevices, PRINT_FUNCTION_VERBOSE, and DltDaemon::storage_handle.

Referenced by dlt_daemon_logstorage_sync_cache().

int dlt_daemon_logstorage_get_loglevel ( DltDaemon daemon,
int  max_device,
char *  apid,
char *  ctid 
)

dlt_daemon_logstorage_get_loglevel

Obtain log level as a union of all configured storage devices and filters for the provided application id and context id

Parameters
daemonPointer to DLT Daemon structure
max_deviceMaximum storage devices setup by the daemon
apidApplication ID
ctidContext ID
Returns
Log level on success, -1 on error

Definition at line 431 of file dlt_daemon_offline_logstorage.c.

References config, DltLogStorage::config_status, dlt_logstorage_get_config(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_MAX, DltLogStorageConfigData::log_level, NULL, and DltDaemon::storage_handle.

Referenced by dlt_daemon_process_user_message_register_context().

void dlt_daemon_logstorage_reset_application_loglevel ( DltDaemon daemon,
int  dev_num,
int  max_device,
int  verbose 
)

dlt_daemon_logstorage_reset_application_loglevel

Reset storage log level of all running applications 2 steps for resetting

  1. Setup storage_loglevel of all contexts configured for the requested device to -1
  2. Re-run update log level for all other configured devices
Parameters
daemonPointer to DLT Daemon structure
dev_numNumber of attached DLT Logstorage device
max_deviceMaximum storage devices setup by the daemon
verboseIf set to true verbose information is printed out

Definition at line 303 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::config_status, DltLogStorage::connection_type, DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL, DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL, dlt_daemon_logstorage_update_application_loglevel(), dlt_log(), dlt_logstorage_update_context_loglevel(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, DltLogStorage::filter_keys, NULL, DltLogStorage::num_filter_keys, PRINT_FUNCTION_VERBOSE, and DltDaemon::storage_handle.

Referenced by dlt_daemon_control_service_logstorage().

void dlt_daemon_logstorage_set_logstorage_cache_size ( unsigned int  size)

Set max size of logstorage cache. Stored internally in bytes

Parameters
sizeSize of logstorage cache [in KB]

Definition at line 573 of file dlt_daemon_offline_logstorage.c.

References g_logstorage_cache_max.

Referenced by option_file_parser().

int dlt_daemon_logstorage_setup_internal_storage ( DltDaemon daemon,
char *  path,
int  verbose 
)

dlt_daemon_logstorage_setup_internal_storage

Setup user defined path as offline log storage device

Parameters
daemonPointer to Dlt Daemon structure
pathUser configured internal storage path
verboseIf set to true verbose information is printed out

Definition at line 541 of file dlt_daemon_offline_logstorage.c.

References dlt_daemon_logstorage_update_application_loglevel(), dlt_log(), dlt_logstorage_device_connected(), dlt_logstorage_load_config(), NULL, and DltDaemon::storage_handle.

Referenced by main().

int dlt_daemon_logstorage_sync_cache ( DltDaemon daemon,
DltDaemonLocal daemon_local,
char *  mnt_point,
int  verbose 
)

Sync logstorage caches

Parameters
daemonPointer to Dlt Daemon structure
daemon_localPointer to Dlt Daemon Local structure
mount_pointLogstorage device mount point
verboseIf set to true verbose information is printed out
Returns
0 on success, -1 otherwise

Definition at line 607 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::connection_type, dlt_daemon_logstorage_get_device(), dlt_logstorage_sync_caches(), DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DltDaemonLocal::flags, NULL, DltDaemonFlags::offlineLogstorageMaxDevices, PRINT_FUNCTION_VERBOSE, and DltDaemon::storage_handle.

Referenced by dlt_daemon_control_service_logstorage().

void dlt_daemon_logstorage_update_application_loglevel ( DltDaemon daemon,
int  dev_num,
int  verbose 
)

dlt_daemon_logstorage_update_application_loglevel

Update log level of all running applications with new filter configuration available due to newly attached DltLogstorage device. The log level is only updated when the current application log level is less than the log level obtained from the storage configuration file

Parameters
daemonPointer to DLT Daemon structure
dev_numNumber of attached DLT Logstorage device
verboseIf set to true verbose information is printed out

Definition at line 374 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::config_status, DltLogStorage::connection_type, dlt_log(), dlt_logstorage_get_loglevel_by_key(), dlt_logstorage_update_context_loglevel(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, DltLogStorage::filter_keys, NULL, DltLogStorage::num_filter_keys, PRINT_FUNCTION_VERBOSE, and DltDaemon::storage_handle.

Referenced by dlt_daemon_control_service_logstorage(), dlt_daemon_logstorage_reset_application_loglevel(), and dlt_daemon_logstorage_setup_internal_storage().

void dlt_daemon_logstorage_write ( DltDaemon daemon,
DltDaemonFlags user_config,
unsigned char *  data1,
int  size1,
unsigned char *  data2,
int  size2,
unsigned char *  data3,
int  size3 
)

dlt_daemon_logstorage_write

Write log message to all attached storage device. If the called dlt_logstorage_write function is not able to write to the device, DltDaemon will disconnect this device.

Parameters
daemonPointer to Dlt Daemon structure
user_configDltDaemon configuration
data1message header buffer
size1message header buffer size
data2message extended header buffer
size2message extended header size
data3message data buffer
size3message data size

Definition at line 477 of file dlt_daemon_offline_logstorage.c.

References DltLogStorage::config_status, dlt_log(), dlt_logstorage_device_disconnected(), DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT, dlt_logstorage_write(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DltLogStorageUserConfig::logfile_counteridxlen, DltLogStorageUserConfig::logfile_delimiter, DltLogStorageUserConfig::logfile_maxcounter, DltLogStorageUserConfig::logfile_timestamp, NULL, DltDaemonFlags::offlineLogstorageDelimiter, DltDaemonFlags::offlineLogstorageMaxCounter, DltDaemonFlags::offlineLogstorageMaxCounterIdx, DltDaemonFlags::offlineLogstorageMaxDevices, DltDaemonFlags::offlineLogstorageTimestamp, and DltDaemon::storage_handle.

Referenced by dlt_daemon_client_send().

int dlt_logstorage_split_key ( char *  key,
char *  appid,
char *  ctxid 
)

dlt_logstorage_split_key

Split a given key into appid and ctxid. If APID: - appid = APID and ctxid = .* If :CTID - ctxid = CTID and appid = .* Else appid = APID and ctxid = CTID

Parameters
keyGiven key of filter hash map
appidApplication id
ctxidContext id
Returns
0 on success, -1 on error

Definition at line 44 of file dlt_daemon_offline_logstorage.c.

References DLT_ID_SIZE, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, and NULL.

Referenced by dlt_logstorage_update_context_loglevel().

int dlt_logstorage_update_all_contexts ( DltDaemon daemon,
char *  id,
int  curr_log_level,
int  cmp_flag,
int  verbose 
)

dlt_logstorage_update_all_contexts

Update log level of all contexts of the application by updating the daemon internal table The compare flags (cmp_flag) indicates if Id has to be compared with application ID or Context id of the daemon internal table The log levels are reset if current log level provided is -1 (not sent to application in this case) Reset and sent to application if current log level provided is 0

Parameters
daemonDltDaemon structure
idapplication id or context id
curr_log_levellog level to be set to context
cmp_flagcompare flag (1 id is apid, 2 id is ctxid)
verboseIf set to true verbose information is printed out
Returns
0 on success, -1 on error

Definition at line 121 of file dlt_daemon_offline_logstorage.c.

References DltDaemonContext::apid, DltDaemon::contexts, DltDaemonContext::ctid, DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL, dlt_daemon_user_send_log_level(), DLT_ID_SIZE, dlt_log(), DLT_OFFLINE_LOGSTORAGE_MAX, dlt_set_id(), NULL, DltDaemon::num_contexts, and DltDaemonContext::storage_log_level.

Referenced by dlt_logstorage_update_context_loglevel().

int dlt_logstorage_update_context ( DltDaemon daemon,
char *  apid,
char *  ctxid,
int  curr_log_level,
int  verbose 
)

dlt_logstorage_update_context

Update log level of a context by updating the daemon internal table The log levels are reset if current log level provided is -1 (not sent to application in this case) Reset and sent to application if current log level provided is 0

Parameters
daemonDltDaemon structure
apidapplication id
ctxidcontext id
curr_log_levellog level to be set to context
verboseIf set to true verbose information is printed out
Returns
0 on success, -1 on error

Definition at line 193 of file dlt_daemon_offline_logstorage.c.

References dlt_daemon_context_find(), DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL, dlt_daemon_user_send_log_level(), dlt_log(), DLT_OFFLINE_LOGSTORAGE_MAX, NULL, and DltDaemonContext::storage_log_level.

Referenced by dlt_logstorage_update_context_loglevel().

int dlt_logstorage_update_context_loglevel ( DltDaemon daemon,
char *  key,
int  curr_log_level,
int  verbose 
)

dlt_logstorage_update_context_loglevel

Update all contexts or particular context depending provided key

Parameters
daemonPointer to DLT Daemon structure
keyFilter key stored in Hash Map
curr_log_levellog level to be set to context
verboseIf set to true verbose information is printed out
Returns
0 on success, -1 on error

Definition at line 247 of file dlt_daemon_offline_logstorage.c.

References DLT_ID_SIZE, dlt_log(), dlt_logstorage_split_key(), dlt_logstorage_update_all_contexts(), dlt_logstorage_update_context(), NULL, and PRINT_FUNCTION_VERBOSE.

Referenced by dlt_daemon_logstorage_reset_application_loglevel(), and dlt_daemon_logstorage_update_application_loglevel().