Changeset 14 in libcf for trunk/src/cf_log.c


Ignore:
Timestamp:
01/31/13 22:55:37 (11 years ago)
Author:
cheese
Message:

#1 add test code and fix debug and logging error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_log.c

    r13 r14  
    22 * cf_log.c
    33 */
     4#ifdef _WIN32
     5# define _USE_32BIT_TIME_T
     6#endif
     7
    48#include "cf_log.h"
    59#include "cf_file.h"
     
    1418
    1519#ifdef _WIN32
     20# define snprintf       _snprintf
    1621# include <Windows.h>
    1722#else // #ifdef _WIN32
     
    2429
    2530#define LOCK_LOG_CTX(__ctx)                     \
    26     if (CF_Mutex_Lock (&__ctx->mutex) < 0)      \
    27         return CF_ERROR_LOG_LOCK_CTX
     31    CF_Mutex_Lock (&__ctx->mutex)
    2832
    2933#define UNLOCK_LOG_CTX(__ctx)                   \
    30     if (CF_Mutex_Unlock (&__ctx->mutex) < 0)    \
    31         return CF_ERROR_LOG_UNLOCK_CTX
     34    CF_Mutex_Unlock (&__ctx->mutex)
    3235
    3336#define CF_LOG_BUFFER_DEFAULT_SIZE      128 * 1024
     
    146149    CF_Log_Local_GetTime (&dt);
    147150
    148     sprintf (buffer, "%02d-%02d-%02d %02d:%02d:%02d.%03d",
    149                      dt.year, dt.month, dt.day,
    150                      dt.hour, dt.min, dt.sec, dt.usec);
     151   
     152
     153    snprintf (buffer, strlen ("0000-00-00 00:00:00.000"),
     154              "%02d-%02d-%02d %02d:%02d:%02d.%03d",
     155              dt.year, dt.month, dt.day,
     156              dt.hour, dt.min, dt.sec, dt.usec);
    151157
    152158    return CF_OK;
     
    287293    if (context->buffer != NULL)
    288294    {
    289         /* FIXME : write residual data in buffer */
    290 
     295        CF_Log_Flush (ctx);
    291296        free (context->buffer);
    292297        context->buffer = NULL;
Note: See TracChangeset for help on using the changeset viewer.