|
| 1 | +import { strictEqual } from 'assert'; |
| 2 | +import { Logger, LogLevel, getConfigLogLevel } from '../src/services/logging'; |
| 3 | + |
| 4 | +suite('Logging', () => { |
| 5 | + const logger = new Logger(); |
| 6 | + test('Set and Get log level', () => { |
| 7 | + logger.setLogLevel(LogLevel.DEBUG); |
| 8 | + strictEqual(LogLevel.DEBUG, logger.getLogLevel()); |
| 9 | + }); |
| 10 | + |
| 11 | + test('Ignore low level messages', () => { |
| 12 | + logger.setLogLevel(LogLevel.NONE); |
| 13 | + logger.debug('This should not be logged'); |
| 14 | + logger.info('This should not be logged'); |
| 15 | + logger.warn('This should not be logged'); |
| 16 | + logger.error('This should not be logged'); |
| 17 | + // FIXME: We cannot yet read the output channel |
| 18 | + // https://github.com/microsoft/vscode/issues/65108 |
| 19 | + strictEqual(true, true); |
| 20 | + }); |
| 21 | + |
| 22 | + test('debug', () => { |
| 23 | + logger.setLogLevel(LogLevel.DEBUG); |
| 24 | + logger.debug('This should be logged'); |
| 25 | + logger.debug('This should be logged', { foo: 'bar' }); |
| 26 | + }); |
| 27 | + |
| 28 | + test('info', () => { |
| 29 | + logger.setLogLevel(LogLevel.INFO); |
| 30 | + logger.info('This should be logged'); |
| 31 | + logger.info('This should be logged', { foo: 'bar' }); |
| 32 | + }); |
| 33 | + |
| 34 | + test('warn', () => { |
| 35 | + logger.setLogLevel(LogLevel.WARN); |
| 36 | + logger.warn('This should be logged'); |
| 37 | + logger.warn('This should be logged', { foo: 'bar' }); |
| 38 | + }); |
| 39 | + |
| 40 | + test('error', () => { |
| 41 | + logger.setLogLevel(LogLevel.ERROR); |
| 42 | + logger.error('This should be logged'); |
| 43 | + logger.error('This should be logged', 'This is an error message'); |
| 44 | + logger.error('This should be logged', new Error('This is an error')); |
| 45 | + }); |
| 46 | + |
| 47 | + test('getConfigLogLevel', () => { |
| 48 | + strictEqual(LogLevel.DEBUG, getConfigLogLevel()); |
| 49 | + }); |
| 50 | + |
| 51 | + test('show', () => { |
| 52 | + logger.show(); |
| 53 | + }); |
| 54 | +}); |
0 commit comments