Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit b6fa498

Browse files
feat: recreate logger (DX-181) (#54)
BREAKING CHANGE: using the latest version of pino and not wrapping it in a custom logger class
1 parent bea10e3 commit b6fa498

33 files changed

+5362
-2197
lines changed

.depcheckrc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
2-
"specials": ["bin", "eslint", "lint-staged", "istanbul", "commitizen", "husky", "prettier", "ttypescript"],
2+
"specials": [
3+
"bin",
4+
"eslint",
5+
"lint-staged",
6+
"istanbul",
7+
"commitizen",
8+
"husky",
9+
"prettier"
10+
],
311
"ignores": [
412
"@commitlint/*",
513
"@types/*",
6-
"@voiceflow/commitlint-config",
14+
"@voiceflow/tsconfig",
715
"@voiceflow/git-branch-check",
8-
"prettier-eslint-cli",
16+
"@voiceflow/commitlint-config",
17+
"@voiceflow/semantic-release-config",
18+
"eslint-import-resolver-typescript",
919
"fixpack",
1020
"husky",
11-
"lint-staged"
21+
"istanbul",
22+
"lint-staged",
23+
"pino-pretty"
1224
]
1325
}

.eslintignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
coverage
2-
.idea
32
.nyc_output
4-
scratch.js
5-
/node_modules
63
/build
7-
nyc_coverage*
4+
/node_modules

.eslintrc.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
module.exports = {
2-
extends: ['@voiceflow/eslint-config', 'plugin:@typescript-eslint/recommended'],
3-
parser: '@typescript-eslint/parser',
4-
plugins: ['@typescript-eslint'],
2+
extends: ['@voiceflow/eslint-config', '@voiceflow/eslint-config/typescript'],
53
overrides: [
64
{
7-
files: ['*.ts'],
8-
extends: ['@voiceflow/eslint-config/typescript'],
5+
files: ['test/**/*'],
6+
extends: ['@voiceflow/eslint-config/utility', '@voiceflow/eslint-config/mocha'],
97
rules: {
10-
'class-methods-use-this': 'off',
11-
'no-param-reassign': 'off',
12-
'import/no-cycle': 'off',
8+
// off
9+
'no-unused-expressions': 'off',
1310
},
1411
},
1512
],

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn git-branch-check

.huskyrc.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,26 @@
11
[![circle ci](https://circleci.com/gh/voiceflow/logger.svg?style=shield&circle-token=8c4e4ce8d04d87f16e903bd7e1ccab194a118262)](https://circleci.com/gh/voiceflow/logger)
22
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=voiceflow_logger&metric=coverage)](https://sonarcloud.io/dashboard?id=voiceflow_logger)
33
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=voiceflow_logger&metric=alert_status)](https://sonarcloud.io/dashboard?id=voiceflow_logger)
4-
# logger
5-
6-
Author: Frank Gu <<[email protected]>>
7-
Date: Dec 11, 2019
84

9-
A logging package for VERY fast and useful JSON logging.
5+
# logger
106

11-
- All log entries go to `process.stdout`
12-
- Minimal overhead and no logger hierarchies
13-
- Multiple instantiations allowed
7+
A standardized package for logging built on `pino`.
148

159
## Usage
1610

17-
```javascript
18-
const Logger = require('@voiceflow/logger').default;
19-
// or
20-
import Logger from '@voiceflow/logger';
21-
22-
const defaultOptions = {
23-
level: 'info',
24-
pretty: false,
25-
};
26-
27-
const overrideOptions = {
28-
level: 'trace', // Minimum log-level to be printed
29-
pretty: true, // Pretty print
30-
};
31-
32-
const defaultLogger = new Logger(); // Default options
33-
const customLogger = new Logger(overrideOptions);
34-
35-
defaultLogger.trace('this is a trace');
36-
defaultLogger.debug('this is a debug');
37-
defaultLogger.info('this is an info');
38-
defaultLogger.warn('this is a warning');
39-
defaultLogger.error('this is an error');
40-
defaultLogger.fatal('this is a fatal');
41-
42-
customLogger.trace('this is a trace');
43-
customLogger.debug('this is a debug');
44-
customLogger.info('this is an info');
45-
customLogger.warn('this is a warning');
46-
customLogger.error('this is an error');
47-
customLogger.fatal('this is a fatal');
48-
```
11+
```ts
12+
import { createLogger, LogLevel, LogFormat } from '@voiceflow/logger';
4913

50-
### Development Assitance
14+
const logger = createLogger({ format: LogFormat.JSON, level: LogLevel.INFO });
5115

52-
- For `warn` logs, the calling function and line number is included
53-
- For `error` and `fatal` logs, the full call-stack is included
16+
const inlineLogger = createLogger({ format: LogFormat.INLINE, level: LogLevel.WARN });
5417

55-
### Pretty Printing
18+
const detailedLogger = createLogger({ format: LogFormat.DETAILED, level: LogLevel.TRACE });
5619

57-
Pretty printing will add colors, parse unix epoch timestamps into UTC time.
20+
logger.trace('this is a trace log');
21+
logger.debug('this is a debug log');
22+
logger.info('this is an info log');
23+
logger.warn('this is a warning log');
24+
logger.error('this is an error log');
25+
logger.fatal('this is a fatal log');
26+
```

config/test/.mocharc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require:
2+
- source-map-support/register
3+
4+
timeout: 4000
5+
exit: true
6+
recursive: true

config/tests/mocha.opts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)