-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from AliMD/feat/refactor-log
Complete refactor logger and fix all packages type issues
- Loading branch information
Showing
18 changed files
with
485 additions
and
194 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import {createLogger} from '@vatr/logger'; | ||
|
||
const log = createLogger('loggerScope', 'info'); | ||
const error = createLogger('loggerScope', 'error', true); | ||
const logger = createLogger('logger/demo', 'green'); | ||
|
||
log('Hello ;)'); | ||
error('Err: Hello ;) - Forced to log'); | ||
console.debug('--- logger.logProperty ---'); | ||
logger.logProperty('name', 'ali'); | ||
logger.logProperty('options', {a: 1, b: 2}); | ||
|
||
console.debug('--- logger.logMethod ---'); | ||
logger.logMethod('myMethod'); | ||
|
||
console.debug('--- logger.logMethodArgs ---'); | ||
logger.logMethodArgs('myMethod', {a: 1, b: 2}); | ||
|
||
console.debug('--- logger.logMethodFull ---'); | ||
logger.logMethodFull('add', {a: 1, b: 2}, 3); | ||
|
||
console.debug('--- logger.incident ---'); | ||
logger.incident('myMethod', 'abort_signal', 'Aborted signal received', {url: '/test.json'}); | ||
|
||
console.debug('--- logger.accident ---'); | ||
logger.accident('myMethod', 'file_not_found', 'Url requested return 404 not found', {url: '/test.json'}); | ||
|
||
console.debug('--- logger.logOther ---'); | ||
logger.logOther('foo:', 'bar', {a: 1}); | ||
|
||
console.debug('--- logger.error ---'); | ||
try { | ||
throw new Error('my_error_message'); | ||
} catch (err) { | ||
logger.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2}); | ||
} |
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 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
Oops, something went wrong.