From c9496d17980bbc9a2c5b30742e6ff1ff7ec299b2 Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Wed, 9 Nov 2011 22:04:30 +0100 Subject: Added dlt-daemon internal logging configuration into dlt.conf file. Internal logging to file now also possible. --- include/dlt/dlt_common.h | 12 ++++- src/daemon/dlt-daemon.c | 90 ++++++++++++++++------------------- src/daemon/dlt-daemon.h | 3 ++ src/daemon/dlt.conf | 11 +++++ src/daemon/dlt_daemon_common.c | 9 ++-- src/shared/dlt_common.c | 83 ++++++++++++++++++++++++--------- src/shared/dlt_shm.c | 103 +++++++++++++++++++++++------------------ 7 files changed, 190 insertions(+), 121 deletions(-) diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 67371be..be315a0 100755 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -861,9 +861,19 @@ extern "C" */ int dlt_file_free(DltFile *file,int verbose); + /** + * Set internal logging filename if mode 2 + * @param filename the filename + */ + void dlt_log_set_filename(const char *filename); + /** + * Set internal logging level + * @param level the level + */ + void dlt_log_set_level(int level); /** * Initialize (external) logging facility - * @param mode positive, if syslog should be used; zero for console output + * @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file */ void dlt_log_init(int mode); /** diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 4ab628f..fb8b2e6 100755 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -135,7 +135,6 @@ void usage() printf("DLT logging daemon\n"); printf("Options:\n"); printf(" -d Daemonize\n"); - printf(" -v Verbose mode\n"); printf(" -h Usage\n"); printf(" -c filename DLT daemon configuration file (Default: /etc/dlt.conf)\n"); } /* usage() */ @@ -158,15 +157,10 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[]) opterr = 0; - while ((c = getopt (argc, argv, "hvdc:")) != -1) + while ((c = getopt (argc, argv, "hdc:")) != -1) { switch (c) { - case 'v': - { - daemon_local->flags.vflag = 1; - break; - } case 'd': { daemon_local->flags.dflag = 1; @@ -230,6 +224,9 @@ int option_file_parser(DltDaemonLocal *daemon_local) daemon_local->flags.offlineTraceDirectory[0] = 0; daemon_local->flags.offlineTraceFileSize = 1000000; daemon_local->flags.offlineTraceMaxSize = 0; + daemon_local->flags.loggingMode = 0; + daemon_local->flags.loggingLevel = 6; + strncpy(daemon_local->flags.loggingFilename,"/tmp/dlt.log",sizeof(daemon_local->flags.loggingFilename)); /* open configuration file */ if(daemon_local->flags.cvalue[0]) @@ -246,7 +243,6 @@ int option_file_parser(DltDaemonLocal *daemon_local) /* fetch line from configuration file */ if ( fgets (line , 1024 , pFile) != NULL ) { - //printf("Line: %s\n",line); pch = strtok (line," =\r\n"); token[0]=0; value[0]=0; @@ -275,100 +271,108 @@ int option_file_parser(DltDaemonLocal *daemon_local) if(strcmp(token,"Verbose")==0) { daemon_local->flags.vflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"PrintASCII")==0) { daemon_local->flags.aflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"PrintHex")==0) { daemon_local->flags.xflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"PrintHeadersOnly")==0) { daemon_local->flags.sflag = atoi(value); - printf("Option: %s=%s\n",token,value); - } - else if(strcmp(token,"Daemonize")==0) - { - daemon_local->flags.dflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"SendSerialHeader")==0) { daemon_local->flags.lflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"SendContextRegistration")==0) { daemon_local->flags.rflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"SendMessageTime")==0) { daemon_local->flags.sendMessageTime = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"RS232SyncSerialHeader")==0) { daemon_local->flags.mflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"TCPSyncSerialHeader")==0) { daemon_local->flags.nflag = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"RS232DeviceName")==0) { strncpy(daemon_local->flags.yvalue,value,sizeof(daemon_local->flags.yvalue)); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"RS232Baudrate")==0) { strncpy(daemon_local->flags.bvalue,value,sizeof(daemon_local->flags.bvalue)); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"ECUId")==0) { strncpy(daemon_local->flags.evalue,value,sizeof(daemon_local->flags.evalue)); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"PersistanceStoragePath")==0) { strncpy(daemon_local->flags.ivalue,value,sizeof(daemon_local->flags.ivalue)); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); + } + else if(strcmp(token,"LoggingMode")==0) + { + daemon_local->flags.loggingMode = atoi(value); + //printf("Option: %s=%s\n",token,value); + } + else if(strcmp(token,"LoggingLevel")==0) + { + daemon_local->flags.loggingLevel = atoi(value); + //printf("Option: %s=%s\n",token,value); + } + else if(strcmp(token,"LoggingFilename")==0) + { + strncpy(daemon_local->flags.loggingFilename,value,sizeof(daemon_local->flags.loggingFilename)); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"SharedMemorySize")==0) { daemon_local->flags.sharedMemorySize = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"OfflineTraceDirectory")==0) { strncpy(daemon_local->flags.offlineTraceDirectory,value,sizeof(daemon_local->flags.offlineTraceDirectory)); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"OfflineTraceFileSize")==0) { daemon_local->flags.offlineTraceFileSize = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else if(strcmp(token,"OfflineTraceMaxSize")==0) { daemon_local->flags.offlineTraceMaxSize = atoi(value); - printf("Option: %s=%s\n",token,value); + //printf("Option: %s=%s\n",token,value); } else { fprintf(stderr, "Unknown option: %s=%s\n",token,value); } } - //printf ("Token: %s\n",pch); - } else { @@ -414,8 +418,10 @@ int main(int argc, char* argv[]) return -1; } - /* Initialize logging facility */ - dlt_log_init(daemon_local.flags.dflag); + /* Initialize internal logging facility */ + dlt_log_set_filename(daemon_local.flags.loggingFilename); + dlt_log_set_level(daemon_local.flags.loggingLevel); + dlt_log_init(daemon_local.flags.loggingMode); /* Print version information */ dlt_get_version(version); @@ -545,22 +551,6 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in signal(SIGQUIT, dlt_daemon_signal_handler); signal(SIGINT, dlt_daemon_signal_handler); -#if 0 - /* open DLT output file */ - daemon_local->ohandle=-1; - if (daemon_local->flags.ovalue[0]) - { - daemon_local->ohandle = open(daemon_local->flags.ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */ - if (daemon_local->ohandle == -1) - { - /* Return value ignored, dlt daemon will exit */ - dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag); - sprintf(str,"Output file %s cannot be opened!\n",daemon_local->flags.ovalue); - dlt_log(LOG_ERR, str); - return -1; - } /* if */ - } /* if */ -#endif /* init offline trace */ if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) && daemon_local->flags.offlineTraceDirectory[0]) { diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index 9d71a6e..bc3ba39 100755 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -110,6 +110,9 @@ typedef struct char offlineTraceDirectory[256]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */ int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */ int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */ + int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */ + int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */ + char loggingFilename[256]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */ } DltDaemonFlags; /** diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf index 629794d..a410d19 100644 --- a/src/daemon/dlt.conf +++ b/src/daemon/dlt.conf @@ -30,6 +30,17 @@ SharedMemorySize = 40000 # Directory where to store the persistant configuration (Default: /tmp) # PersistanceStoragePath = /tmp +# The logging console for internal logging of dlt-daemon (Default: 0) +# 0 = log to stdout, 1 = log to syslog, 2 = log to file (see LoggingFilename) +LoggingMode = 2 + +# The internal log level, up to which logs are written (Default: 6) +# LOG_EMERG = 0, LOG_ALERT = 1, LOG_CRIT = 2, LOG_ERR = 3, LOG_WARNING = 4, LOG_NOTICE = 5, LOG_INFO = 6, LOG_DEBUG = 7 +LoggingLevel = 6 + +# The logging filename if internal logging mode is log to file (Default: /tmp/log) +LoggingFilename = /tmp/dlt.log + ######################################################################## # Offline Trace memory # ######################################################################## diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index dbb1e7a..4877825 100755 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -907,11 +907,13 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve if(strcmp(token,"LoggingMode")==0) { daemon->mode = atoi(value); - printf("Option: %s=%s\n",token,value); + sprintf(str,"Runtime Option: %s=%d\n",token,daemon->mode); + dlt_log(LOG_INFO, str); } else { - fprintf(stderr, "Unknown option: %s=%s\n",token,value); + sprintf(str,"Unknown option: %s=%s\n",token,value); + dlt_log(LOG_ERR, str); } } } @@ -924,7 +926,8 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve } else { - fprintf(stderr, "Cannot open configuration file: %s\n",filename); + sprintf(str,"Cannot open configuration file: %s\n",filename); + dlt_log(LOG_WARNING, str); } return 0; diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 4ac7dbe..bf363b7 100755 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -114,7 +114,11 @@ static char str[DLT_COMMON_BUFFER_LENGTH]; const char dltSerialHeader[DLT_ID_SIZE] = { 'D','L','S',1 }; char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D','L','S',1 }; -static int log_as_daemon = 0; +/* internal logging parameters */ +static int logging_mode = 0; +static int logging_level = 6; +static char logging_filename[256] = ""; +static FILE *logging_handle = 0; char *message_type[] = {"log","app_trace","nw_trace","control","","","",""}; char *log_info[] = {"","fatal","error","warn","info","debug","verbose","","","","","","","","",""}; @@ -1952,14 +1956,37 @@ int dlt_file_free(DltFile *file,int verbose) return dlt_message_free(&(file->msg),verbose); } +void dlt_log_set_level(int level) +{ + logging_level = level; +} + +void dlt_log_set_filename(const char *filename) +{ + strncpy(logging_filename,filename,sizeof(logging_filename)); +} + void dlt_log_init(int mode) { - log_as_daemon = mode; + logging_mode = mode; + + if(logging_mode == 2) + { + /* internal logging to file */ + logging_handle = fopen(logging_filename,"w"); + if (logging_handle == 0) + { + printf("Internal log file %s cannot be opened!\n",logging_filename); + return; + } + } } void dlt_log_free(void) { - /* Nothing to be done yet */ + if(logging_mode == 2) { + fclose(logging_handle); + } } int dlt_log(int prio, char *s) @@ -1970,68 +1997,80 @@ int dlt_log(int prio, char *s) { return -1; } + if(logging_level #include +#if !defined(_MSC_VER) +#include +#include +#endif + #include #include @@ -98,12 +103,13 @@ void dlt_shm_pv(int id,int operation) semaphor.sem_flg = SEM_UNDO; if(semop(id, &semaphor,1) == -1) { - perror("SHM: semop"); + dlt_log(LOG_ERR,"SHM: semop"); } } int dlt_shm_init_server(DltShm *buf,int key,int size) { struct shmid_ds shm_buf; + char str[256]; // Init parameters buf->shm = NULL; @@ -114,32 +120,32 @@ int dlt_shm_init_server(DltShm *buf,int key,int size) { // Create the segment. if ((buf->shmid = shmget(key, size, IPC_CREAT | 0666)) < 0) { - perror("SHM: shmget"); + dlt_log(LOG_ERR,"SHM: shmget"); return -1; /* ERROR */ } // get the size of shm if (shmctl(buf->shmid, IPC_STAT, &shm_buf)) { - perror("SHM: shmctl"); + dlt_log(LOG_ERR,"SHM: shmctl"); return -1; /* ERROR */ } // Now we attach the segment to our data space. if ((buf->shm = shmat(buf->shmid, NULL, 0)) == (char *) -1) { - perror("SHM: shmat"); + dlt_log(LOG_ERR,"SHM: shmat"); return -1; /* ERROR */ } // Init semaphore if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT|IPC_EXCL)) == -1 ) { if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_EXCL)) == -1 ) { - perror("SHM: semget"); + dlt_log(LOG_ERR,"SHM: semget"); return -1; /* ERROR */ } } if( semctl(buf->semid,0,SETVAL,(int)1) == -1 ) { - perror("SHM: semctl"); + dlt_log(LOG_ERR,"SHM: semctl"); return -1; /* ERROR */ } @@ -153,9 +159,8 @@ int dlt_shm_init_server(DltShm *buf,int key,int size) { // clear memory memset(buf->mem,0,buf->size); - //dlt_shm_status(buf); - //dlt_shm_info(buf); - printf("SHM: Size %d\n",buf->size); + snprintf(str,sizeof(str),"SHM: Size %d\n",buf->size); + dlt_log(LOG_INFO, str); return 0; /* OK */ } @@ -172,26 +177,26 @@ int dlt_shm_init_client(DltShm *buf,int key) { // Create the segment. if ((buf->shmid = shmget(key, 0, 0666)) < 0) { - perror("SHM: shmget"); + dlt_log(LOG_ERR,"SHM: shmget"); return -1; /* ERROR */ } // get the size of shm if (shmctl(buf->shmid, IPC_STAT, &shm_buf)) { - perror("SHM: shmctl"); + dlt_log(LOG_ERR,"SHM: shmctl"); return -1; /* ERROR */ } // Now we attach the segment to our data space. if ((buf->shm = shmat(buf->shmid, NULL, 0)) == (char *) -1) { - perror("shmat"); + dlt_log(LOG_ERR,"shmat"); return -1; /* ERROR */ } // Init semaphore if( (buf->semid = semget(DLT_SHM_SEM,0,0)) == -1 ) { - perror("SHM: semget"); + dlt_log(LOG_ERR,"SHM: semget"); return -1; /* ERROR */ } DLT_SHM_SEM_FREE(buf->semid); @@ -208,26 +213,34 @@ int dlt_shm_init_client(DltShm *buf,int key) { void dlt_shm_info(DltShm *buf) { + char str[256]; - printf("SHM: SHM id: %d\n",buf->shmid); - printf("SHM: Available size: %d\n",buf->size); - printf("SHM: SHM full start address: %lX\n",(unsigned long)buf->shm); - printf("SHM: SHM start address: %lX\n",(unsigned long)buf->mem); + snprintf(str,sizeof(str),"SHM: SHM id: %d\n",buf->shmid); + dlt_log(LOG_INFO, str); + snprintf(str,sizeof(str),"SHM: Available size: %d\n",buf->size); + dlt_log(LOG_INFO, str); + snprintf(str,sizeof(str),"SHM: SHM full start address: %lX\n",(unsigned long)buf->shm); + dlt_log(LOG_INFO, str); + snprintf(str,sizeof(str),"SHM: SHM start address: %lX\n",(unsigned long)buf->mem); + dlt_log(LOG_INFO, str); } void dlt_shm_status(DltShm *buf) { int write, read, count; + char str[256]; write = ((int*)(buf->shm))[0]; read = ((int*)(buf->shm))[1]; count = ((int*)(buf->shm))[2]; - printf("SHM: Write: %d\n",write); - printf("SHM: Read: %d\n",read); - printf("SHM: Count: %d\n",count); - + snprintf(str,sizeof(str),"SHM: Write: %d\n",write); + dlt_log(LOG_INFO, str); + snprintf(str,sizeof(str),"SHM: Read: %d\n",read); + dlt_log(LOG_INFO, str); + snprintf(str,sizeof(str),"SHM: Count: %d\n",count); + dlt_log(LOG_INFO, str); } int dlt_shm_get_total_size(DltShm *buf) @@ -267,7 +280,7 @@ int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const if(!buf->mem) { // shm not initialised - //printf("SHM: SHM not initialised\n"); + //dlt_log(LOG_ERR,"SHM: SHM not initialised\n"); return -1; /* ERROR */ } @@ -283,13 +296,13 @@ int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const if(read==write && count) { // shm buffer is full DLT_SHM_SEM_FREE(buf->semid); - //printf("SHM is totally full\n"); + //dlt_log(LOG_ERR,"SHM is totally full\n"); return -1; // ERROR } else if(write >= buf->size) { if((size1+size2+size3+sizeof(head)+sizeof(unsigned char)+sizeof(int)) > read) { DLT_SHM_SEM_FREE(buf->semid); - //printf("SHM is full at start\n"); + //dlt_log(LOG_ERR,"SHM is full at start\n"); return -1; // ERROR } write = 0; @@ -297,7 +310,7 @@ int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const else if(read > write) { if((write + size1+size2+size3+sizeof(head)+sizeof(unsigned char)+sizeof(int)) > read) { DLT_SHM_SEM_FREE(buf->semid); - //printf("SHM is full at end\n"); + //dlt_log(LOG_ERR,"SHM is full at end\n"); return -1; // ERROR } } @@ -308,7 +321,7 @@ int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const // try write at beginning if((size1+size2+size3+sizeof(head)+sizeof(unsigned char)+sizeof(int)) > read) { DLT_SHM_SEM_FREE(buf->semid); - //printf("SHM is full at start\n"); + //dlt_log(LOG_ERR,"SHM is full at start\n"); return -1; // ERROR } // write zero status and size at end if possible @@ -359,7 +372,7 @@ int dlt_shm_pull(DltShm *buf,unsigned char *data, int max_size) if(!buf->mem) { // shm not initialised - printf("SHM: SHM not initialised\n"); + //dlt_log(LOG_ERR,"SHM: SHM not initialised\n"); return -1; /* ERROR */ } @@ -398,19 +411,19 @@ int dlt_shm_pull(DltShm *buf,unsigned char *data, int max_size) // check status if(status != 2 ) { - //printf("Buffer is not fully written\n"); + //dlt_log(LOG_ERR,"Buffer is not fully written\n"); return -1; // ERROR } // plausibility check of buffer size if( (read+size) > buf->size) { - printf("SHM: Buffers size bigger than shm buffer\n"); + dlt_log(LOG_ERR,"SHM: Buffers size bigger than shm buffer\n"); return -1; // ERROR } // check max read size if(size > max_size) { - printf("SHM: Buffer is bigger than max size\n"); + dlt_log(LOG_ERR,"SHM: Buffer is bigger than max size\n"); return -1; // ERROR } @@ -442,7 +455,7 @@ int dlt_shm_copy(DltShm *buf,unsigned char *data, int max_size) if(!buf->mem) { // shm not initialised - printf("SHM: SHM not initialised\n"); + dlt_log(LOG_ERR,"SHM: SHM not initialised\n"); return -1; /* ERROR */ } DLT_SHM_SEM_FREE(buf->semid); @@ -482,19 +495,19 @@ int dlt_shm_copy(DltShm *buf,unsigned char *data, int max_size) // check status if(status != 2 ) { - //printf("Buffer is not fully written\n"); + //dlt_log(LOG_ERR,"Buffer is not fully written\n"); return -1; // ERROR } // plausibility check of buffer size if( (read+size) > buf->size) { - printf("SHM: Buffers size bigger than shm buffer\n"); + dlt_log(LOG_ERR,"SHM: Buffers size bigger than shm buffer\n"); return -1; // ERROR } // check max read size if((size-sizeof(head)) > max_size) { - printf("SHM: Buffer is bigger than max size\n"); + dlt_log(LOG_ERR,"SHM: Buffer is bigger than max size\n"); return -1; // ERROR } @@ -511,7 +524,7 @@ int dlt_shm_remove(DltShm *buf) if(!buf->mem) { // shm not initialised - printf("SHM: SHM not initialised\n"); + dlt_log(LOG_ERR,"SHM: SHM not initialised\n"); return -1; /* ERROR */ } @@ -551,13 +564,13 @@ int dlt_shm_remove(DltShm *buf) // check status if(status != 2 ) { - //printf("Buffer is not fully written\n"); + //dlt_log(LOG_ERR,"Buffer is not fully written\n"); return -1; // ERROR } // plausibility check of buffer size if( (read+size) > buf->size) { - printf("SHM: Buffers size bigger than shm buffer\n"); + dlt_log(LOG_ERR,"SHM: Buffers size bigger than shm buffer\n"); return -1; // ERROR } @@ -570,7 +583,7 @@ int dlt_shm_remove(DltShm *buf) int dlt_shm_reset(DltShm *buf) { - printf("SHM: Pointer corrupted; reset triggered.\n"); + dlt_log(LOG_EMERG,"SHM: Pointer corrupted; reset triggered.\n"); /* reset pointers and counters */ DLT_SHM_SEM_GET(buf->semid); @@ -589,7 +602,7 @@ int dlt_shm_recover(DltShm *buf) { // initialise head head[3] = 0x01; - printf("SHM: Head not found; try to recover.\n"); + dlt_log(LOG_EMERG,"SHM: Head not found; try to recover.\n"); /* try to find next valid message */ DLT_SHM_SEM_GET(buf->semid); @@ -643,22 +656,22 @@ int dlt_shm_recover(DltShm *buf) { int dlt_shm_free_server(DltShm *buf) { if(!buf->shm) { - printf("SHM: Shared memory segment not attached\n"); + dlt_log(LOG_ERR,"SHM: Shared memory segment not attached\n"); return -1; /* ERROR */ } if(shmdt(buf->shm)) { - perror("SHM: shmdt"); + dlt_log(LOG_ERR,"SHM: shmdt"); return -1; /* ERROR */ } if(shmctl(buf->shmid,IPC_RMID,NULL) == -1) { - perror("SHM: shmdt"); + dlt_log(LOG_ERR,"SHM: shmdt"); return -1; /* ERROR */ } if(semctl(buf->semid,0,IPC_RMID,(int)0) == -1) { - perror("SHM: shmdt"); + dlt_log(LOG_ERR,"SHM: shmdt"); return -1; /* ERROR */ } @@ -675,12 +688,12 @@ int dlt_shm_free_server(DltShm *buf) { int dlt_shm_free_client(DltShm *buf) { if(!buf->shm) { - printf("SHM: Shared memory segment not attached\n"); + dlt_log(LOG_ERR,"SHM: Shared memory segment not attached\n"); return -1; /* ERROR */ } if(shmdt(buf->shm)) { - perror("SHM: shmdt"); + dlt_log(LOG_ERR,"SHM: shmdt"); return -1; /* ERROR */ } -- cgit v1.2.1