-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: rework Console to use NativeConsole subclass
- Loading branch information
1 parent
3a8be7a
commit 46f3618
Showing
5 changed files
with
166 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Copyright (c) 2023, Brian Frank and Andy Frank | ||
// Licensed under the Academic Free License version 3.0 | ||
// | ||
// History: | ||
// 18 Jun 24 Brian Frank Creation | ||
// | ||
|
||
/** | ||
* Console | ||
*/ | ||
fan.util.NativeConsole = fan.sys.Obj.$extend(fan.util.Console); | ||
|
||
fan.util.NativeConsole.prototype.$ctor = function() {} | ||
fan.util.NativeConsole.prototype.$typeof = function() { return fan.util.NativeConsole.$type; } | ||
|
||
fan.util.NativeConsole.curNative = function() { return fan.util.NativeConsole.$curNative; } | ||
|
||
fan.util.NativeConsole.$curNative = new fan.util.NativeConsole(); | ||
|
||
fan.util.NativeConsole.prototype.debug = function(msg) { console.debug(msg); return this; } | ||
|
||
fan.util.NativeConsole.prototype.info = function(msg) { console.info(msg); return this; } | ||
|
||
fan.util.NativeConsole.prototype.warn = function(msg) { console.warn(msg); return this; } | ||
|
||
fan.util.NativeConsole.prototype.err = function(msg) { console.error(msg); return this; } | ||
|
||
fan.util.NativeConsole.prototype.width = function() { return null; } | ||
|
||
fan.util.NativeConsole.prototype.height = function() { return null; } | ||
|
||
fan.util.NativeConsole.prototype.table = function(obj) | ||
{ | ||
var grid = [] | ||
var t = fan.util.ConsoleTable.make(obj); | ||
for (var r=0; r<t.rows().size(); ++r) | ||
{ | ||
var row = t.rows().get(r); | ||
var obj = {}; | ||
for (var c=0; c<t.headers().size(); ++c) | ||
{ | ||
var key = t.headers().get(c); | ||
var val = row.get(c); | ||
obj[key] = val; | ||
} | ||
grid.push(obj); | ||
} | ||
console.table(grid) | ||
return this; | ||
} | ||
|
||
fan.util.NativeConsole.prototype.group = function(msg, collapsed) | ||
{ | ||
if (!collapsed) | ||
console.group(msg) | ||
else | ||
console.groupCollapsed(msg); | ||
return this; | ||
} | ||
|
||
fan.util.NativeConsole.prototype.groupEnd = function() | ||
{ | ||
console.groupEnd(); | ||
return this; | ||
} | ||
|
||
fan.util.NativeConsole.prototype.prompt = function(msg) | ||
{ | ||
return null; // unsupported | ||
} | ||
|
||
fan.util.NativeConsole.prototype.promptPassword = function(msg) | ||
{ | ||
return null; // unsupported | ||
} | ||
|