KNHAPI(void) knh_printf(Ctx *ctx, knh_OutputStream_t *w, const char *fmt, ...) { va_list ap; va_start(ap , fmt); knh_vprintf(ctx, w, fmt, ap); va_end(ap); }
void knh_vperror(Ctx *ctx, knh_uri_t uri, int line, int pe, const char *fmt, va_list ap) { DBG_ASSERT(pe <= LOG_DEBUG); if(knh_Gamma_isQuiet(ctx->gma)) { return; } // if(pe < KERR_DWARN) { // DP(ctx->gma)->statError += 1; // } // else if(pe < KERR_TINFO) { // DP(ctx->gma)->statBadManner += 1; // } if(knh_Context_isInteractive(ctx)) { goto L_PRINT; } if(pe > KERR_EWARN && !knh_Context_isCompiling(ctx)) { return; } L_PRINT:; if(line > 0) { knh_OutputStream_t *w = KNH_STDERR; knh_printf(ctx, w, " - [%s:%d]:%s ", FILENAME__(uri), (knh_intptr_t)line, KERR_tochar(pe)); knh_vprintf(ctx, w, fmt, ap); knh_write_EOL(ctx, w); } else { knh_vsyslog(ctx, pe, fmt, ap); } }
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 knh_vperror(Ctx *ctx, knh_uri_t uri, int line, int pe, char *fmt, va_list ap) { KNH_ASSERT(pe <= KERR_INFO); if(knh_Context_isInteractive(ctx)) { goto L_PRINT; } if(pe > KERR_EWARN && !knh_Context_isCompiling(ctx)) { return; } L_PRINT:; { OutputStream *w = KNH_STDERR; knh_printf(ctx, w, " - [%s:%d]:%s ", knh_safefile(URIDN(uri)), (knh_intptr_t)line, KERR_MSG[pe]); knh_vprintf(ctx, w, fmt, ap); knh_write_EOL(ctx, w); ((Context*)ctx)->hasError = 1; } }
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 }
static knh_String_t *Gamma_vperror(CTX ctx, int pe, const char *fmt, va_list ap) { knh_String_t *msg = TS_EMPTY; int isPRINT = (pe <= KC_DWARN) ? 1 : 0; if(pe != KC_DEBUG && (CTX_isInteractive(ctx) || knh_isCompileOnly(ctx))) { isPRINT = 1; } if(Gamma_isQuiet(ctx->gma) || ctx->gma->uline == 0) { isPRINT = 0; } //DBG_P("/*isPRINT=%d*/ uline=%d", isPRINT, ctx->gma->uline); if(isPRINT == 1) { knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf); knh_write_uline(ctx, cwb->w, ctx->gma->uline); knh_write_ascii(ctx, cwb->w, KC__(pe)); knh_vprintf(ctx, cwb->w, fmt, ap); msg = knh_cwb_newString(ctx, cwb); knh_Array_add(ctx, DP(ctx->gma)->errmsgs, msg); fprintf(stderr, "%s - %s%s\n", TERM_BNOTE(ctx, pe), S_tochar(msg), TERM_ENOTE(ctx, pe)); } return msg; }