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.build = function(fn) { if (!debug.show) return; fn(); }
debug.show = true; debug.show = true;
debug.urnames = false; debug.urnames = false;
debug.termout = true;
debug.fn_break = function(fn,obj = globalThis) { debug.fn_break = function(fn,obj = globalThis) {
if (typeof fn !== 'function') return; if (typeof fn !== 'function') return;

View file

@ -179,6 +179,7 @@ console.transcript = "";
console.say = function (msg) { console.say = function (msg) {
msg += "\n"; msg += "\n";
console.print(msg); console.print(msg);
if (debug.termout) console.term_print(msg);
console.transcript += msg; console.transcript += msg;
}; };
console.log = console.say; 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_print, log_print(str))
JSC_SCALL(console_term_print, term_print(str));
JSValue js_console_rec(JSContext *js, JSValue self, int argc, JSValue *argv) 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[] = { static const JSCFunctionListEntry js_console_funcs[] = {
MIST_FUNC_DEF(console,print,1), MIST_FUNC_DEF(console,print,1),
MIST_FUNC_DEF(console, term_print, 1),
MIST_FUNC_DEF(console,rec,4), MIST_FUNC_DEF(console,rec,4),
CGETSET_ADD(global, stdout_lvl) 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) void log_print(const char *str)
{ {
#ifndef NDEBUG #ifndef NDEBUG
fprintf(stdout, "%s", str);
fprintf(writeout, "%s", str); fprintf(writeout, "%s", str);
fflush(stdout);
#else #else
printf(str); printf(str);
fflush(stdout); fflush(stdout);
#endif #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) { 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; lvl = LOG_PANIC-lvl;
mYughLog(LOG_RENDER, lvl, line, file, "tag: %s, id: %d, msg: %s", tag, id, msg); 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 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 log_print(const char *str);
void term_print(const char *str);
#endif #endif