例
このセクションでは、通知のさまざまな例をリストします。
- I_ERRLOG 通知の例を以下に示します。
struct strioctl ioc; ioc.ic_cmd = I_ERRLOG; ioc.ic_timout = 0; /* default timeout (15 secs.)*/ ioc.ic_len = 0; ioc.ic_dp = NULL; ioctl(log, I_STR, &ioc); - I_TRCLOG 通知の例を以下に示します。
struct trace_ids tid[2]; tid[0].ti_mid = 2; tid[0].ti_sid = 0; tid[0].ti_level = 1; tid[1].ti_mid = 1002; tid[1].ti_sid = -1; /* any sub-id will be allowed*/ tid[1].ti_level = -1; /* any level will be allowed*/ ioc.ic_cmd = I_TRCLOG; ioc.ic_timeout = 0; ioc.ic_len = 2 * sizeof(struct trace_ids); ioc.ic_dp = (char *)tid; ioctl(log, I_STR, &ioc); - 以下は、ログ・メッセージ (引数なし) をサブミットする例です。
struct strbuf ctl, dat; struct log_ctl lc; char *message = "Honey, I'm working late again."; ctl.len = ctl.maxlen = sizeof(lc); ctl.buf = (char *)&lc; dat.len = dat.maxlen = strlen(message); dat.buf = message; lc.level = 0 lc.flags = SL_ERROS; putmsg(log, &ctl, &dat, 0);