void knh_makeEvidence(Ctx *ctx, const char *ns, const char *event, int p, const char *fmt, ...)
{
	if(p > LOG_WARNING && !knh_isSystemVerbose()) return;
	va_list ap;
	va_start(ap , fmt);
	if(fmt[0] == '*') {
		char newfmt[512];
		knh_snprintf(newfmt, sizeof(newfmt), K_EVENT_FORMAT "%s", ns, event, fmt+1);
		ctx->share->ebiSPI->vsyslog(p, newfmt, ap);
	}
	else {
		DBG_ASSERT(ctx->bufa != NULL);
		knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf);
		knh_printf(ctx, cwb->w, K_EVENT_FORMAT, ns, event);
		if(ctx->gma != NULL && SP(ctx->gma)->line != 0) {
			knh_write_uline(ctx, cwb->w, SP(ctx->gma)->uri, SP(ctx->gma)->line);
		}
		knh_vprintf(ctx, cwb->w, fmt, ap);
		ctx->share->ebiSPI->syslog(p, knh_cwb_tochar(ctx, cwb));
		knh_cwb_clear(cwb, 0);
	}
	va_end(ap);
	if(p == LOG_EMERG || p == LOG_CRIT) {
#if defined(K_USING_DEBUG)
		DBG_ABORT();
#endif
		knh_exit(ctx, 0);
	}
}
void dbg_p(const char *file, const char *func, int line, const char *fmt, ...)
{
#ifndef K_USING_DEBUG
	if(knh_isSystemVerbose()) {
#endif
		va_list ap;
		va_start(ap , fmt);
		fflush(stdout);
		fprintf(stderr, "DEBUG(%s:%d) ", func, line);
		vfprintf(stderr, fmt, ap);
		fprintf(stderr, "\n");
		va_end(ap);
#ifndef K_USING_DEBUG
	}
#endif
}
示例#3
0
文件: i.c 项目: shinpei/konoha-wand
static void ClassMETHOD_man(CTX ctx, knh_OutputStream_t *w, const knh_ClassTBL_t *ct, knh_NameSpace_t *ns)
{
	size_t i, cnt = 0, hasCaption = 0;
	knh_Array_t *a = ct->methods;
	for(i = 0; i < knh_Array_size(a); i++) {
		knh_Method_t *mtd = a->methods[i];
		if(mtd->mn < MN_OPSIZE) continue;
		if(MN_isFMT(mtd->mn)) continue;
		if(Method_isHidden(mtd) && !knh_isSystemVerbose()) continue;
		if(hasCaption == 0) {
			knh_write_ctext(ctx, w, _("METHOD"));
			hasCaption = 1;
		}
		knh_write_Method(ctx, w, ct, mtd);
		cnt++;
	}
	if(hasCaption == 1) {
		knh_write_EOL(ctx, w);
	}
}
static void knh_vsyslog(Ctx *ctx, int p, const char *fmt, va_list ap)
{
	if(p > LOG_WARNING && !knh_isSystemVerbose()) return;
#ifdef KONOHA_ON_LKM
	//TODO_IDE();
	vprintk(fmt, ap);
#else
	if(ctx == NULL) {
		fprintf(stderr, "konoha[%s] ", LOG__(p));
		vfprintf(stderr, fmt, ap);
		fprintf(stderr, "\n");
	}
	else {
		knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf);
		knh_printf(ctx, cwb->w, "konoha[%s] ", LOG__(p));
		knh_vprintf(ctx, cwb->w, fmt, ap);
		fprintf(stderr, "%s\n", knh_cwb_tochar(ctx, cwb));
		knh_cwb_clear(cwb, 0);
	}
#endif
}