Navigation


Changeset 710:e60376cb15e8 in freeDiameter for libfdproto/msg_log.c


Ignore:
Timestamp:
Feb 10, 2011, 4:00:53 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/msg_log.c

    r689 r710  
    109109        FILE * fstr;
    110110       
     111        char buftime[256];
     112        size_t offset = 0;
     113        struct timespec ts;
     114        struct tm tm;
     115       
    111116        TRACE_ENTRY("%d %p %p", cause, msg, prefix_format);
    112117        CHECK_PARAMS_DO( (cause >= 0) && (cause <= FD_MSG_LOG_MAX),
     
    125130        CHECK_POSIX_DO( pthread_mutex_unlock(&ml_conf.lock), );
    126131       
     132        /* Get current time */
     133        CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &ts), /* continue */);
     134        offset += strftime(buftime + offset, sizeof(buftime) - offset, "%D,%T", localtime_r( &ts.tv_sec , &tm ));
     135        offset += snprintf(buftime + offset, sizeof(buftime) - offset, ".%6.6ld", ts.tv_nsec / 1000);
     136       
     137
    127138        /* Okay, now we will create the file descriptor */
    128139        switch (meth) {
     
    142153       
    143154        /* For file methods, let's parse the message so it looks better */
    144         if ((meth != FD_MSG_LOGTO_DEBUGONLY) && ml_conf.dict) {
     155        if (((meth != FD_MSG_LOGTO_DEBUGONLY) || (fd_g_debug_lvl > FULL)) && ml_conf.dict) {
    145156                CHECK_FCT_DO( fd_msg_parse_dict( msg, ml_conf.dict, NULL ), );
    146157        }
     
    155166        pthread_cleanup_pop(0);
    156167        (void)pthread_mutex_unlock(&fd_log_lock);
    157         fd_log_debug_fstr(fstr, "\n\n");
     168       
     169        fd_log_debug_fstr(fstr, "\nLogged: %s\n\n", buftime);
    158170       
    159171        /* And now the message itself */
    160         fd_msg_dump_fstr(msg, fstr);
     172        if ((meth == FD_MSG_LOGTO_DEBUGONLY) && (fd_g_debug_lvl <= INFO)) {
     173                /* dump only the header */
     174                fd_msg_dump_fstr_one(msg, fstr);
     175        } else {
     176                /* dump the full content */
     177                fd_msg_dump_fstr(msg, fstr);
     178        }
    161179       
    162180        /* And finally close the stream if needed */
    163         TODO("close?");
     181        switch (meth) {
     182                case FD_MSG_LOGTO_DEBUGONLY:
     183                        break;
     184                       
     185                case FD_MSG_LOGTO_FILE:
     186                        TODO("close?");
     187                        break;
     188                case FD_MSG_LOGTO_DIR:
     189                        TODO("close?");
     190                        break;
     191        }
    164192}
    165193
Note: See TracChangeset for help on using the changeset viewer.