op_prg_log_entry_write()
摘要
向指定的日志句柄写入一条日志条目。
语法
op_prg_log_entry_write (handle, entry_text, …)
| 参数 | 类型 | 说明 |
|---|---|---|
handle |
Log_Handle |
标识接收该条目的仿真日志的日志句柄。 |
entry_text |
const char* |
包含日志条目文本的字符串。该字符串可以包含类似 C 语言 printf 命令使用的转换说明符(%d、%s 等)。 |
… |
various |
零个或多个参数,表示要替换到 entry_text 中的值。 |
返回类型
void
无返回值。
示例
节选自 models/std/atm 目录中的 ams_atm_notif_log_support_v2.ex.c。
/* Write the message to the notification log */
op_prg_log_entry_write (atm_buff_overflow_cell_loss_log_handle,
"SYMPTOM(S):\n"
" A Cell is being dropped as there is \n"
" no available space at output buffer \n"
" of port [%d] for the QoS %s \n"
"\n"
"CAUSE(S):\n"
" Cells can be dropped at the end nodes\n"
" or switches due to non-availability \n"
" of buffer space at the output ports. \n"
" The buffers need to be sufficient \n"
" to hold cells generated due to a \n"
" burst. \n"
"\n"
"SUGGESTION(S):\n"
" 1. Set the buffer sizes for QoS \n"
" %s to be greater than \n"
" the present value of %d. \n"
"\n",
port_value,
qos_string,
qos_string,
cur_buf_size
);
详情
该内核过程向仿真日志追加一条新的日志条目。日志条目将带有基于生成该条目的事件的仿真时间的时间戳。
仿真日志只能由类型为 Log_Handle 且已通过 op_prg_log_handle_create() 初始化的变量引用。
用途
提供一种向指定仿真日志写入条目的机制。
错误
- 可恢复错误:日志句柄无效。
- 可恢复错误:空句柄格式。
- 程序中止:段错误/总线错误。(由于跟在带转换说明符的字符串之后的参数无效)
参考
- 使用内核过程 op_prg_log_handle_create() 创建日志句柄
- 使用内核过程 op_prg_log_entry_write_options() 写入省略所选列值的日志条目
- 使用内核过程 op_prg_log_entry_write_t() 写入带有用户指定时间戳的日志条目
- 使用内核过程 op_prg_log_handle_severity_set() 在写入日志条目之前更改严重性级别