add alternate output term path

This commit is contained in:
John Alanbrook 2024-08-24 18:46:21 -05:00
parent 39cbd92bfb
commit 9fd958f414
5 changed files with 11 additions and 2 deletions

View file

@ -1,6 +1,7 @@
debug.build = function(fn) { if (!debug.show) return; fn(); }
debug.show = true;
debug.urnames = false;
debug.termout = true;
debug.fn_break = function(fn,obj = globalThis) {
if (typeof fn !== 'function') return;

View file

@ -179,6 +179,7 @@ console.transcript = "";
console.say = function (msg) {
msg += "\n";
console.print(msg);
if (debug.termout) console.term_print(msg);
console.transcript += msg;
};
console.log = console.say;

View file

@ -1625,6 +1625,7 @@ static const JSCFunctionListEntry js_time_funcs[] = {
};
JSC_SCALL(console_print, log_print(str))
JSC_SCALL(console_term_print, term_print(str));
JSValue js_console_rec(JSContext *js, JSValue self, int argc, JSValue *argv)
{
@ -1645,6 +1646,7 @@ JSC_GETSET_GLOBAL(stdout_lvl, number)
static const JSCFunctionListEntry js_console_funcs[] = {
MIST_FUNC_DEF(console,print,1),
MIST_FUNC_DEF(console, term_print, 1),
MIST_FUNC_DEF(console,rec,4),
CGETSET_ADD(global, stdout_lvl)
};

View file

@ -108,15 +108,19 @@ void mYughLog(int category, int priority, int line, const char *file, const char
void log_print(const char *str)
{
#ifndef NDEBUG
fprintf(stdout, "%s", str);
fprintf(writeout, "%s", str);
fflush(stdout);
#else
printf(str);
fflush(stdout);
#endif
}
void term_print(const char *str)
{
fprintf(stdout, "%s", str);
fflush(stdout);
}
void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) {
lvl = LOG_PANIC-lvl;
mYughLog(LOG_RENDER, lvl, line, file, "tag: %s, id: %d, msg: %s", tag, id, msg);

View file

@ -41,5 +41,6 @@ void mYughLog(int category, int priority, int line, const char *file, const char
void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data);
void log_print(const char *str);
void term_print(const char *str);
#endif