design_pattern_for_c  V 1.00
dp_timelog.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <config.h>
#include "dp_debug.h"
#include "dp_mutex.h"
Include dependency graph for dp_timelog.c:

Go to the source code of this file.

Data Structures

struct  dp_timelog_data_t
 log data with timestamp, defined like class More...
 
struct  dp_timelog_t
 storaged log data management structure More...
 

Macros

#define DPTLOG_DELIMITER_DEFAULT   (char *)" "
 default delimiter definition More...
 
#define DPTLOG_LOCK(mng)   DPUTIL_LOCK(mng->lock)
 
#define DPTLOG_UNLOCK   DPUTIL_UNLOCK;
 
Error definition
#define DPTLOG_FAILED   (-1) /*! error */
 
#define DPTLOG_SUCCESS   (0) /*! success */
 

Typedefs

typedef struct dp_timelog_data_t dp_timelog_data_t
 

Functions

static void dp_timelog_show (DPTimeLog mng)
 
DPTimeLog dp_timelog_init (const char *delimiter, size_t maxloglen, unsigned long maxstoresize, int is_threadsafe)
 Init store log. More...
 
int dp_timelog_print (DPTimeLog mng, const char *format,...)
 Store log. More...
 
void dp_timelog_exit (DPTimeLog mng)
 Exit stored log, and show stored log. More...
 
log class API for dp_timelog_data_t
static void dp_timelog_data_store (DPTimeLog mng)
 for dp_timelog_data_t More...
 

Variables

DPTimeLog timelog_g
 Implement of dp_timelog API, defined in dp_debug.h. More...
 

Macro Definition Documentation

◆ DPTLOG_DELIMITER_DEFAULT

#define DPTLOG_DELIMITER_DEFAULT   (char *)" "

default delimiter definition

Definition at line 26 of file dp_timelog.c.

◆ DPTLOG_FAILED

#define DPTLOG_FAILED   (-1) /*! error */

Definition at line 21 of file dp_timelog.c.

◆ DPTLOG_LOCK

#define DPTLOG_LOCK (   mng)    DPUTIL_LOCK(mng->lock)

Definition at line 57 of file dp_timelog.c.

◆ DPTLOG_SUCCESS

#define DPTLOG_SUCCESS   (0) /*! success */

Definition at line 22 of file dp_timelog.c.

◆ DPTLOG_UNLOCK

#define DPTLOG_UNLOCK   DPUTIL_UNLOCK;

Definition at line 58 of file dp_timelog.c.

Typedef Documentation

◆ dp_timelog_data_t

Function Documentation

◆ dp_timelog_data_store()

static void dp_timelog_data_store ( DPTimeLog  mng)
inlinestatic

for dp_timelog_data_t

Definition at line 66 of file dp_timelog.c.

Here is the caller graph for this function:

◆ dp_timelog_exit()

void dp_timelog_exit ( DPTimeLog  handle)

Exit stored log, and show stored log.

Parameters
[in]handlehandle returned from timelog_init
Returns
none

Definition at line 162 of file dp_timelog.c.

Here is the call graph for this function:

◆ dp_timelog_init()

DPTimeLog dp_timelog_init ( const char *  delimiter,
size_t  maxloglen,
unsigned long  maxstoresize,
int  is_threadsafe 
)

Init store log.

Parameters
[in]delimiterdelimiter string if you want, default:" "
[in]maxloglenMax length of logs
[in]maxstoresizeStoraged log size. If 0, always show log
[in]is_threadsafethreadsafe or not
Return values
!NULLhandle pointer to use other method
NULLerror

Definition at line 85 of file dp_timelog.c.

◆ dp_timelog_print()

int dp_timelog_print ( DPTimeLog  handle,
const char *  format,
  ... 
)

Store log.

Parameters
[in]handlehandle returned from timelog_init
[in]formatlog format as printf
Return values
0<=valsuccess
otherfailed (same as prinf)

Definition at line 139 of file dp_timelog.c.

Here is the call graph for this function:

◆ dp_timelog_show()

static void dp_timelog_show ( DPTimeLog  mng)
static

Definition at line 74 of file dp_timelog.c.

Here is the caller graph for this function:

Variable Documentation

◆ timelog_g

DPTimeLog timelog_g

Implement of dp_timelog API, defined in dp_debug.h.

global timelog handle to show debug log

Definition at line 14 of file dp_timelog.c.