github.com/kaleido-io/firefly@v0.0.0-20210622132723-8b4b6aacb971/kat/src/test/ethereum/lib/logging.ts (about) 1 // Copyright © 2021 Kaleido, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 import { Logger, setLogLevel } from '../../../lib/logging'; 16 17 export const testLogging = async () => { 18 19 describe('Logging', () => { 20 21 it('logs all the levels', () => { 22 23 setLogLevel('trace') 24 25 const logger = new Logger('unit test'); 26 logger.error('this is an error message'); 27 logger.warn('this is an warning message'); 28 logger.warn('this is an info message'); 29 logger.debug('this is a debug message'); 30 logger.trace('this is a trace message'); 31 32 // Log empty 33 logger.info(); 34 35 // Log a dodgy axios message exercising paths 36 logger.info({ 37 isAxiosError: true, 38 }) 39 40 // Log an axios error that looks like a stream 41 logger.info({ 42 isAxiosError: true, 43 response: { 44 data: { 45 on: () => null, 46 }, 47 }, 48 }) 49 50 }); 51 52 }); 53 };