log_output.c

システムログのフォーマット出力 [詳細]

#include <t_services.h>

log_output.cのインクルード依存関係図

ソースコードを見る。

マクロ定義

#define _intptr_   long

関数

static void convert (unsigned _intptr_ val, unsigned int radix, const char *radchar, int width, int minus, int padzero, void(*putc)(char))
void syslog_printf (const char *format, VP_INT *args, void(*putc)(char))
void syslog_print (SYSLOG *p_log, void(*putc)(char))
void syslog_output (void(*putc)(char))

変数

static const char raddec [] = "0123456789"
static const char radhex [] = "0123456789abcdef"
static const char radHEX [] = "0123456789ABCDEF"


説明

システムログのフォーマット出力

log_output.c で定義されています。


マクロ定義

#define _intptr_   long
 

log_output.c51 行で定義されています。

参照元 syslog_printf().


関数

static void convert unsigned _intptr_  val,
unsigned int  radix,
const char *  radchar,
int  width,
int  minus,
int  padzero,
void(*)(char)  putc
[static]
 

log_output.c58 行で定義されています。

参照元 syslog_printf().

00060 {
00061     char    buf[12];
00062     int i, j;
00063 
00064     i = 0;
00065     do {
00066         buf[i++] = radchar[val % radix];
00067         val /= radix;
00068     } while (val != 0);
00069 
00070     width -= minus;
00071     if (minus > 0 && padzero > 0) {
00072         (*putc)('-');
00073     }
00074     for (j = i; j < width; j++) {
00075         (*putc)((char)(padzero > 0 ? '0' : ' '));
00076     }
00077     if (minus > 0 && padzero <= 0) {
00078         (*putc)('-');
00079     }
00080     while (i > 0) {
00081         (*putc)(buf[--i]);
00082     }
00083 }

void syslog_output void(*)(char)  putc  ) 
 

log_output.c182 行で定義されています。

参照先 LOG_TYPE_COMMENTSYSLOG::logtypesyslog_print()syslog_printf()vrea_log().

参照元 logtask().

00183 {
00184     static const char   lostmsg[] = "%d messages are lost.";
00185     SYSLOG  log;
00186     INT lostnum, n;
00187 
00188     lostnum = 0;
00189     while ((n = vrea_log(&log)) >= 0) {
00190         lostnum += n;
00191         if (log.logtype < LOG_TYPE_COMMENT) {
00192             continue;
00193         }
00194         if (lostnum > 0) {
00195             syslog_printf(lostmsg, (VP_INT *) &lostnum, putc);
00196             lostnum = 0;
00197         }
00198         syslog_print(&log, putc);
00199     }
00200     if (lostnum > 0) {
00201         syslog_printf(lostmsg, (VP_INT *) &lostnum, putc);
00202     }
00203 }

関数の呼び出しグラフ:

void syslog_print SYSLOG p_log,
void(*)(char)  putc
 

log_output.c167 行で定義されています。

参照先 LOG_TYPE_ASSERTLOG_TYPE_COMMENTSYSLOG::loginfoSYSLOG::logtypesyslog_printf().

参照元 syslog_output().

00168 {
00169     switch (p_log->logtype) {
00170     case LOG_TYPE_COMMENT:
00171         syslog_printf((const char *)(p_log->loginfo[0]),
00172                     &(p_log->loginfo[1]), putc);
00173         break;
00174     case LOG_TYPE_ASSERT:
00175         syslog_printf("%s:%u: Assertion `%s' failed.",
00176                     &(p_log->loginfo[0]), putc);
00177         break;
00178     }
00179 }

関数の呼び出しグラフ:

void syslog_printf const char *  format,
VP_INT args,
void(*)(char)  putc
 

log_output.c93 行で定義されています。

参照先 _intptr_convert().

参照元 syslog_output()syslog_print().

00094 {
00095     int     c;
00096     int     width;
00097     int     padzero;
00098     _intptr_    val;
00099     const char  *str;
00100 
00101     while ((c = *format++) != '\0') {
00102         if (c != '%') {
00103             (*putc)((char) c);
00104             continue;
00105         }
00106 
00107         width = padzero = 0;
00108         if ((c = *format++) == '0') {
00109             padzero = 1;
00110             c = *format++;
00111         }
00112         while ('0' <= c && c <= '9') {
00113             width = width * 10 + c - '0';
00114             c = *format++;
00115         }
00116         switch (c) {
00117         case 'd':
00118             val = (_intptr_)(*args++);
00119             if (val >= 0) {
00120                 convert((unsigned _intptr_) val, 10, raddec,
00121                         width, 0, padzero, putc);
00122             }
00123             else {
00124                 convert((unsigned _intptr_)(-val), 10, raddec,
00125                         width, 1, padzero, putc);
00126             }
00127             break;
00128         case 'u':
00129             val = (_intptr_)(*args++);
00130             convert((unsigned _intptr_) val, 10, raddec,
00131                         width, 0, padzero, putc);
00132             break;
00133         case 'x':
00134         case 'p':
00135             val = (_intptr_)(*args++);
00136             convert((unsigned _intptr_) val, 16, radhex,
00137                         width, 0, padzero, putc);
00138             break;
00139         case 'X':
00140             val = (_intptr_)(*args++);
00141             convert((unsigned _intptr_) val, 16, radHEX,
00142                         width, 0, padzero, putc);
00143             break;
00144         case 'c':
00145             (*putc)((char)(_intptr_)(*args++));
00146             break;
00147         case 's':
00148             str = (const char *)(*args++);
00149             while ((c = *str++) != '\0') {
00150                 (*putc)((char) c);
00151             }
00152             break;
00153         case '%':
00154             (*putc)('%');
00155             break;
00156         case '\0':
00157             format--;
00158             break;
00159         default:
00160             break;
00161         }
00162     }
00163     (*putc)('\n');
00164 }

関数の呼び出しグラフ:


変数

const char raddec[] = "0123456789" [static]
 

log_output.c88 行で定義されています。

const char radHEX[] = "0123456789ABCDEF" [static]
 

log_output.c90 行で定義されています。

const char radhex[] = "0123456789abcdef" [static]
 

log_output.c89 行で定義されています。


Copyright © 2006 by TAKAGI Nobuhisa.
このページは Mon Apr 3 23:49:16 2006 に Doxygen によって生成されました。