Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): add missing console.trace #11540

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/Resources/ti.internal/extensions/js/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Console {
this._apiModule[level](string);
} else {
// Support Node.JS streams like stdout/stderr which don't have log levels
const useStdErr = (level === 'warn' || level === 'error');
const useStdErr = (level === 'warn' || level === 'error' || level === 'trace');
const stream = useStdErr ? this._stderr : this._stdout;

if (this._ignoreErrors === false) {
Expand Down Expand Up @@ -134,6 +134,10 @@ class Console {
this._writeToConsole('debug', formatWithOptions(kColorInspectOptions, ...args));
}

trace(...args) {
this._writeToConsole('trace', formatWithOptions(kColorInspectOptions, ...args));
}

clear() {} // no-op

group(...data) {
Expand Down
6 changes: 6 additions & 0 deletions tests/Resources/console.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe('console', function () {
should(console.warn).be.a.Function;
});

it('#trace', () => {
should(console.trace).be.a.Function;
});

it('#time', () => {
should(console.time).be.a.Function;
});
Expand Down Expand Up @@ -294,13 +298,15 @@ describe('console', function () {
console.dirxml('dirxml'); // stdout
console.warn('warn'); // stderr
console.error('error'); // stderr
console.trace('trace'); // stderr
stdout.logs.length.should.eql(3);
stdout.logs[0].should.eql('log');
stdout.logs[1].should.eql('info');
stdout.logs[2].should.eql('dirxml');
stderr.logs.length.should.eql(2);
stderr.logs[0].should.eql('warn');
stderr.logs[1].should.eql('error');
stderr.logs[1].should.eql('trace');
});

it('squashes sync errors on stdout write by default (ignoreErrors = true)', () => {
Expand Down