Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.
Merged
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
20 changes: 16 additions & 4 deletions .depcheckrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"specials": ["bin", "eslint", "lint-staged", "istanbul", "commitizen", "husky", "prettier", "ttypescript"],
"specials": [
"bin",
"eslint",
"lint-staged",
"istanbul",
"commitizen",
"husky",
"prettier"
],
"ignores": [
"@commitlint/*",
"@types/*",
"@voiceflow/commitlint-config",
"@voiceflow/tsconfig",
"@voiceflow/git-branch-check",
"prettier-eslint-cli",
"@voiceflow/commitlint-config",
"@voiceflow/semantic-release-config",
"eslint-import-resolver-typescript",
"fixpack",
"husky",
"lint-staged"
"istanbul",
"lint-staged",
"pino-pretty"
]
}
5 changes: 1 addition & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
coverage
.idea
.nyc_output
scratch.js
/node_modules
/build
nyc_coverage*
/node_modules
13 changes: 5 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
module.exports = {
extends: ['@voiceflow/eslint-config', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['@voiceflow/eslint-config', '@voiceflow/eslint-config/typescript'],
overrides: [
{
files: ['*.ts'],
extends: ['@voiceflow/eslint-config/typescript'],
files: ['test/**/*'],
extends: ['@voiceflow/eslint-config/utility', '@voiceflow/eslint-config/mocha'],
rules: {
'class-methods-use-this': 'off',
'no-param-reassign': 'off',
'import/no-cycle': 'off',
// off
'no-unused-expressions': 'off',
},
},
],
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn git-branch-check
7 changes: 0 additions & 7 deletions .huskyrc.json

This file was deleted.

59 changes: 14 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
[![circle ci](https://circleci.com/gh/voiceflow/logger.svg?style=shield&circle-token=8c4e4ce8d04d87f16e903bd7e1ccab194a118262)](https://circleci.com/gh/voiceflow/logger)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=voiceflow_logger&metric=coverage)](https://sonarcloud.io/dashboard?id=voiceflow_logger)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=voiceflow_logger&metric=alert_status)](https://sonarcloud.io/dashboard?id=voiceflow_logger)
# logger

Author: Frank Gu <<[email protected]>>
Date: Dec 11, 2019

A logging package for VERY fast and useful JSON logging.
# logger

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

## Usage

```javascript
const Logger = require('@voiceflow/logger').default;
// or
import Logger from '@voiceflow/logger';

const defaultOptions = {
level: 'info',
pretty: false,
};

const overrideOptions = {
level: 'trace', // Minimum log-level to be printed
pretty: true, // Pretty print
};

const defaultLogger = new Logger(); // Default options
const customLogger = new Logger(overrideOptions);

defaultLogger.trace('this is a trace');
defaultLogger.debug('this is a debug');
defaultLogger.info('this is an info');
defaultLogger.warn('this is a warning');
defaultLogger.error('this is an error');
defaultLogger.fatal('this is a fatal');

customLogger.trace('this is a trace');
customLogger.debug('this is a debug');
customLogger.info('this is an info');
customLogger.warn('this is a warning');
customLogger.error('this is an error');
customLogger.fatal('this is a fatal');
```
```ts
import { createLogger, LogLevel, LogFormat } from '@voiceflow/logger';

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

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

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

Pretty printing will add colors, parse unix epoch timestamps into UTC time.
logger.trace('this is a trace log');
logger.debug('this is a debug log');
logger.info('this is an info log');
logger.warn('this is a warning log');
logger.error('this is an error log');
logger.fatal('this is a fatal log');
```
6 changes: 6 additions & 0 deletions config/test/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require:
- source-map-support/register

timeout: 4000
exit: true
recursive: true
5 changes: 0 additions & 5 deletions config/tests/mocha.opts

This file was deleted.

7 changes: 0 additions & 7 deletions index.ts

This file was deleted.

31 changes: 0 additions & 31 deletions lib/constants.ts

This file was deleted.

64 changes: 0 additions & 64 deletions lib/createMiddleware.ts

This file was deleted.

68 changes: 0 additions & 68 deletions lib/createTraced.ts

This file was deleted.

Loading