Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions core/packages/logging-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@

export * from './logging-utils';
// 🌟 ADDED EXPORT FOR TYPES 🌟
export type {
LogFields,
LogSeverity,
AdhocDebugLogFunction,
DebugLogBackend,
} from './types';
export {LogSeverity} from './types';
export type {LogFields, AdhocDebugLogFunction, DebugLogBackend} from './types';
2 changes: 1 addition & 1 deletion core/packages/logging-utils/src/logging-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export abstract class DebugLogBackendBase implements DebugLogBackend {
// Look for the Node config variable for what systems to enable. We'll store
// these for the log method below, which will call setFilters() once.
let nodeFlag = process.env[env.nodeEnables] ?? '*';
if (nodeFlag === 'all') {
if (nodeFlag === 'all' || nodeFlag === 'true') {
nodeFlag = '*';
}
this.filters = nodeFlag.split(',');
Expand Down
34 changes: 29 additions & 5 deletions core/packages/logging-utils/test/logging-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import * as assert from 'assert';
import * as sinon from 'sinon';

import * as al from '../src/logging-utils';
import * as al from '../src/index';
import * as alTypes from '../src/types';

interface TestLog {
Expand All @@ -28,7 +28,7 @@
class TestSink extends al.DebugLogBackendBase {
logs: TestLog[] = [];

makeLogger(namespace: string): any {

Check warning on line 31 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return (fields: alTypes.LogFields, ...args: unknown[]) => {
this.logs.push({namespace, fields, args});
};
Expand Down Expand Up @@ -57,13 +57,29 @@
});

it('obeys "all" as an alias for "*"', () => {
al.setBackend(sink);
sink.reset();

process.env[al.env.nodeEnables] = 'all';
const backend = new TestSink();
al.setBackend(backend);
assert.deepStrictEqual(backend.filters, ['*']);
const logger = al.log(system);
logger({}, 'foo');
assert.deepStrictEqual(sink.logs, [
assert.deepStrictEqual(backend.logs, [
{
namespace: system,
fields: {},
args: ['foo'],
},
]);
Comment thread
shivanee-p marked this conversation as resolved.
});

it('obeys "true" as an alias for "*"', () => {
process.env[al.env.nodeEnables] = 'true';
const backend = new TestSink();
al.setBackend(backend);
assert.deepStrictEqual(backend.filters, ['*']);
const logger = al.log(system);
logger({}, 'foo');
assert.deepStrictEqual(backend.logs, [
{
namespace: system,
fields: {},
Expand All @@ -74,7 +90,7 @@
});

describe('Manually enabled', () => {
let logger: any;

Check warning on line 93 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const system = 'basic';

beforeEach(() => {
Expand All @@ -98,7 +114,7 @@
});

describe('Basic enabled', () => {
let logger: any;

Check warning on line 117 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const system = 'basic';

beforeEach(() => {
Expand Down Expand Up @@ -176,7 +192,7 @@
});

describe('Tap', () => {
let logger: any;

Check warning on line 195 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const system = 'taps';

beforeEach(() => {
Expand Down Expand Up @@ -207,7 +223,7 @@
const system = 'structured';
const structured = al.getStructuredBackend(sink);

let logger: any;

Check warning on line 226 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
beforeEach(() => {
al.setBackend(structured);
sink.reset();
Expand Down Expand Up @@ -273,7 +289,7 @@
});

describe('sub-logs', () => {
let logger: any;

Check warning on line 292 in core/packages/logging-utils/test/logging-utils.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const system = 'sublogs';
const subsystem = 'subsys';

Expand All @@ -297,4 +313,12 @@
]);
});
});

it('exports LogSeverity as a runtime enum from index', () => {
assert.strictEqual(al.LogSeverity.DEFAULT, 'DEFAULT');
assert.strictEqual(al.LogSeverity.DEBUG, 'DEBUG');
assert.strictEqual(al.LogSeverity.INFO, 'INFO');
assert.strictEqual(al.LogSeverity.WARNING, 'WARNING');
assert.strictEqual(al.LogSeverity.ERROR, 'ERROR');
});
});
Loading