op_prg_log_entry_write_options()

摘要

向指定的日志句柄写入一条日志条目,并可控制其中包含哪些列。

语法

op_prg_log_entry_write_options (handle, options, entry_text, …)
参数 类型 说明
handle Log_Handle 日志句柄,标识接收该条目的仿真日志。
options int 用于抑制日志条目中某些列的选项(见详情中的 options)。
entry_text const char * 包含日志条目文本的字符串。该字符串可以包含与 C 语言 printf 命令类似的转换说明符(%d、%s 等)。
… various 零个或多个参数,表示要替换到 entry_text 中的值。

返回类型

Compcode

若条目添加成功,返回 OPC_COMPCODE_SUCCESS;否则返回 OPC_COMPCODE_FAILURE。

示例

/* Failed to load the requested model */
/* Most likely cause is missing model from mod_dirs. */

sprintf (line0_buf, "TMM: unable to load propagation model (%s). ",
	DraS_Closure_Tmm_Prop_Model_Name);
strcpy (line1_buf, "Using default closure instead.");

/* log message, omitting node and event */
op_prg_log_entry_write_options (tmm_problem_log_handle, 
	OPC_LOG_ENTRY_OPTION_NO_NODE | OPC_LOG_ENTRY_OPTION_NO_EVENT,
	"Pipeline stage 'closure' during initialization for\n"
	"%s\n"
	"%s\n"
	"\n"
	"Check that your mod_dirs contains all 3 of the needed\n"
	"propagation model files (.prop.d, .prop.p and .prop.so).\n",
	line0_buf,
	line1_buf);

详情

该内核过程向仿真日志追加一条新的日志条目。仿真日志只能由类型为 Log_Handle 且已通过 op_prg_log_handle_create() 初始化的变量引用。

options

可以使用 options 参数从日志条目中省略某些列的值。options 必须为 0(包含所有列),或者是以下一个或多个常量按位 OR 的组合:

  • OPC_LOG_ENTRY_OPTION_NO_EVENT
  • OPC_LOG_ENTRY_OPTION_NO_NODE
  • OPC_LOG_ENTRY_OPTION_NO_SEVERITY
  • OPC_LOG_ENTRY_OPTION_NO_TIME

用途

提供向指定仿真日志写入条目的机制。该内核过程与 op_prg_log_entry_write() 完全相同,不同之处在于它还允许从日志条目中省略所选的列。

错误

  • 可恢复错误:日志句柄无效。
  • 可恢复错误:句柄格式为空。
  • 程序中止:段错误/总线错误(由于在带转换说明符的字符串之后跟了无效参数)。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com