@adonisjs/logger
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -0,4 +1,10 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
/// <reference types="pino" /> | ||
declare module '@ioc:Adonis/Core/Logger' { | ||
import { Level, TimeFn, redactOptions, PrettyOptions, SerializerFn, LevelMapping, DestinationStream } from 'pino'; | ||
/** | ||
* Config shape | ||
*/ | ||
export type LoggerConfigContract = { | ||
@@ -28,2 +34,5 @@ name: string; | ||
}; | ||
/** | ||
* Logger interface that main and fake logger implements | ||
*/ | ||
export interface LoggerContract { | ||
@@ -30,0 +39,0 @@ level: string; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
import { IocContract } from '@adonisjs/fold'; | ||
@@ -2,0 +5,0 @@ export default class LoggerProvider { |
"use strict"; | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +6,0 @@ const Logger_1 = require("../src/Logger"); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
/// <reference path="../adonis-typings/logger.d.ts" /> | ||
@@ -6,5 +9,16 @@ import Pino from 'pino'; | ||
import { Logger } from './Logger'; | ||
/** | ||
* Fake logger that sets a custom logger stream and returns | ||
* the log messages as an array vs writing them to `stdout`. | ||
*/ | ||
export declare class FakeLogger extends Logger { | ||
constructor(config: DeepReadonly<LoggerConfigContract>, pino?: Pino.Logger); | ||
readonly logs: any[]; | ||
/** | ||
* An array of in-memory logs | ||
*/ | ||
get logs(): any[]; | ||
/** | ||
* Returns the child fake logger. All logs from the child | ||
* are writte to the same top level stream | ||
*/ | ||
child(bindings: { | ||
@@ -17,3 +31,6 @@ level?: Pino.Level | string; | ||
}): FakeLogger; | ||
/** | ||
* Clear in-memory logs | ||
*/ | ||
clear(): void; | ||
} |
"use strict"; | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Logger_1 = require("./Logger"); | ||
/** | ||
* Fake logger that sets a custom logger stream and returns | ||
* the log messages as an array vs writing them to `stdout`. | ||
*/ | ||
class FakeLogger extends Logger_1.Logger { | ||
constructor(config, pino) { | ||
/** | ||
* Config is only used when we are not receiving an | ||
* existing instance of pino. | ||
*/ | ||
if (!pino) { | ||
@@ -23,5 +34,12 @@ const cloned = Object.assign({}, config, { | ||
} | ||
/** | ||
* An array of in-memory logs | ||
*/ | ||
get logs() { | ||
return this.$config.stream.logs; | ||
} | ||
/** | ||
* Returns the child fake logger. All logs from the child | ||
* are writte to the same top level stream | ||
*/ | ||
child(bindings) { | ||
@@ -33,2 +51,5 @@ if (!this.$config.enabled) { | ||
} | ||
/** | ||
* Clear in-memory logs | ||
*/ | ||
clear() { | ||
@@ -35,0 +56,0 @@ this.$config.stream.logs = []; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
/// <reference path="../adonis-typings/logger.d.ts" /> | ||
@@ -5,2 +8,5 @@ import Pino from 'pino'; | ||
import { LoggerConfigContract } from '@ioc:Adonis/Core/Logger'; | ||
/** | ||
* Returns an instance of pino logger by adjusting the config options | ||
*/ | ||
export declare function getPino(options: DeepReadonly<LoggerConfigContract>): Pino.Logger; |
"use strict"; | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,3 +9,15 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @adonisjs/logger | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
/// <reference path="../adonis-typings/logger.ts" /> | ||
const pino_1 = __importDefault(require("pino")); | ||
/** | ||
* Returns an instance of pino logger by adjusting the config options | ||
*/ | ||
function getPino(options) { | ||
@@ -9,0 +24,0 @@ const pinoOptions = Object.assign({ changeLevelName: options.levelKey || 'level' }, options); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
/// <reference path="../adonis-typings/logger.d.ts" /> | ||
@@ -5,2 +8,7 @@ import Pino from 'pino'; | ||
import { LoggerConfigContract, LoggerContract } from '@ioc:Adonis/Core/Logger'; | ||
/** | ||
* Logger class built on top of pino with couple of changes in | ||
* the configuration. You can access the underlying `pino` | ||
* object using `logger.pino`. | ||
*/ | ||
export declare class Logger implements LoggerContract { | ||
@@ -10,22 +18,65 @@ protected $config: DeepReadonly<LoggerConfigContract>; | ||
constructor($config: DeepReadonly<LoggerConfigContract>, pino?: Pino.Logger); | ||
readonly levels: Pino.LevelMapping; | ||
readonly level: string; | ||
readonly levelNumber: number; | ||
readonly pinoVersion: string; | ||
readonly LOG_VERSION: number; | ||
/** | ||
* A map of levels | ||
*/ | ||
get levels(): Pino.LevelMapping; | ||
/** | ||
* Returns the current logger level | ||
*/ | ||
get level(): string; | ||
/** | ||
* Returns the current logger level number | ||
*/ | ||
get levelNumber(): number; | ||
/** | ||
* Returns the pino version | ||
*/ | ||
get pinoVersion(): string; | ||
/** | ||
* Returns the log formatting version | ||
*/ | ||
get LOG_VERSION(): number; | ||
/** | ||
* Returns a boolean telling if level is enabled or | ||
* not. | ||
*/ | ||
isLevelEnabled(level: string): boolean; | ||
/** | ||
* Log message for any named level | ||
*/ | ||
log(level: string, message: string, ...values: any[]): void; | ||
log(level: string, mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at trace level | ||
*/ | ||
trace(message: string, ...values: any[]): void; | ||
trace(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at debug level | ||
*/ | ||
debug(message: string, ...values: any[]): void; | ||
debug(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at info level | ||
*/ | ||
info(message: string, ...values: any[]): void; | ||
info(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at warn level | ||
*/ | ||
warn(message: string, ...values: any[]): void; | ||
warn(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at error level | ||
*/ | ||
error(message: string, ...values: any[]): void; | ||
error(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Log message at fatal level | ||
*/ | ||
fatal(message: string, ...values: any[]): void; | ||
fatal(mergingObject: any, message: string, ...values: any[]): void; | ||
/** | ||
* Returns a child logger instance | ||
*/ | ||
child(bindings: { | ||
@@ -38,2 +89,5 @@ level?: Pino.Level | string; | ||
}): Logger; | ||
/** | ||
* Returns default bindings for the logger | ||
*/ | ||
bindings(): { | ||
@@ -40,0 +94,0 @@ [key: string]: any; |
"use strict"; | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,2 +9,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @adonisjs/logger | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
/// <reference path="../adonis-typings/logger.ts" /> | ||
const pino_1 = __importDefault(require("pino")); | ||
@@ -28,2 +40,7 @@ const abstract_logging_1 = __importDefault(require("abstract-logging")); | ||
}; | ||
/** | ||
* Logger class built on top of pino with couple of changes in | ||
* the configuration. You can access the underlying `pino` | ||
* object using `logger.pino`. | ||
*/ | ||
class Logger { | ||
@@ -39,2 +56,5 @@ constructor($config, pino) { | ||
} | ||
/** | ||
* A map of levels | ||
*/ | ||
get levels() { | ||
@@ -46,23 +66,39 @@ if (!this.$config.enabled) { | ||
} | ||
/** | ||
* Returns the current logger level | ||
*/ | ||
get level() { | ||
if (!this.$config.enabled) { | ||
return 'info'; | ||
return this.$config.level; | ||
} | ||
return this.pino.level; | ||
} | ||
/** | ||
* Returns the current logger level number | ||
*/ | ||
get levelNumber() { | ||
if (!this.$config.enabled) { | ||
return 30; | ||
return STATIC_LEVELS.values[this.$config.level]; | ||
} | ||
return this.pino.levelVal; | ||
} | ||
/** | ||
* Returns the pino version | ||
*/ | ||
get pinoVersion() { | ||
return pino_1.default.version; | ||
} | ||
/** | ||
* Returns the log formatting version | ||
*/ | ||
get LOG_VERSION() { | ||
if (!this.$config.enabled) { | ||
return 1; | ||
return pino_1.default.LOG_VERSION; | ||
} | ||
return this.pino.LOG_VERSION; | ||
} | ||
/** | ||
* Returns a boolean telling if level is enabled or | ||
* not. | ||
*/ | ||
isLevelEnabled(level) { | ||
@@ -103,2 +139,5 @@ if (!this.$config.enabled) { | ||
} | ||
/** | ||
* Returns a child logger instance | ||
*/ | ||
child(bindings) { | ||
@@ -110,2 +149,5 @@ if (!this.$config.enabled) { | ||
} | ||
/** | ||
* Returns default bindings for the logger | ||
*/ | ||
bindings() { | ||
@@ -112,0 +154,0 @@ if (!this.$config.enabled) { |
@@ -0,2 +1,5 @@ | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
export { Logger } from './src/Logger'; | ||
export { FakeLogger } from './src/FakeLogger'; |
"use strict"; | ||
/** | ||
* @module @adonisjs/logger | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @adonisjs/logger | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
var Logger_1 = require("./src/Logger"); | ||
@@ -4,0 +15,0 @@ exports.Logger = Logger_1.Logger; |
{ | ||
"name": "@adonisjs/logger", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "Logger built on top of pino to be used by AdonisJs", | ||
"main": "build/providers/LoggerProvider.js", | ||
"files": [ | ||
@@ -17,3 +18,3 @@ "build/adonis-typings", | ||
"test": "node japaFile.js", | ||
"lint": "tslint --project tsconfig.json", | ||
"lint": "eslint . --ext=.ts", | ||
"clean": "del build", | ||
@@ -36,5 +37,5 @@ "copyfiles": "copyfiles \"templates/**/*.txt\" build", | ||
"devDependencies": { | ||
"@adonisjs/fold": "^6.1.9", | ||
"@adonisjs/mrm-preset": "^2.1.0", | ||
"@types/node": "^12.7.4", | ||
"@adonisjs/fold": "^6.2.3", | ||
"@adonisjs/mrm-preset": "^2.2.3", | ||
"@types/node": "^12.12.21", | ||
"commitizen": "^4.0.3", | ||
@@ -45,13 +46,13 @@ "copyfiles": "^2.1.1", | ||
"doctoc": "^1.4.0", | ||
"husky": "^3.0.5", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-adonis": "^1.0.4", | ||
"husky": "^3.1.0", | ||
"japa": "^3.0.1", | ||
"mrm": "^1.2.2", | ||
"np": "^5.0.3", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.19.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typedoc": "^0.15.0", | ||
"mrm": "^2.0.2", | ||
"np": "^5.2.1", | ||
"ts-node": "^8.5.4", | ||
"typedoc": "^0.15.5", | ||
"typedoc-plugin-external-module-name": "^2.1.0", | ||
"typedoc-plugin-markdown": "^2.1.11", | ||
"typescript": "^3.6.2" | ||
"typedoc-plugin-markdown": "^2.2.14", | ||
"typescript": "^3.7.4" | ||
}, | ||
@@ -82,6 +83,6 @@ "nyc": { | ||
"dependencies": { | ||
"@types/pino": "^5.8.10", | ||
"abstract-logging": "^1.0.0", | ||
"pino": "^5.13.2", | ||
"ts-essentials": "^3.0.2" | ||
"@types/pino": "^5.15.0", | ||
"abstract-logging": "^2.0.0", | ||
"pino": "^5.15.0", | ||
"ts-essentials": "^4.0.0" | ||
}, | ||
@@ -88,0 +89,0 @@ "directories": { |
@@ -26,3 +26,2 @@ <div align="center"> | ||
- [API](#api) | ||
- [Maintainers](#maintainers) | ||
@@ -59,3 +58,3 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
const providers = [ | ||
'@adonisjs/logger/build/providers/LoggerProvider' | ||
'@adonisjs/logger' | ||
] | ||
@@ -147,4 +146,2 @@ ``` | ||
## Maintainers | ||
[Harminder virk](https://github.com/thetutlage) | ||
@@ -154,8 +151,9 @@ [circleci-image]: https://img.shields.io/circleci/project/github/adonisjs/logger/master.svg?style=for-the-badge&logo=circleci | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[typescript-url]: "typescript" | ||
[npm-image]: https://img.shields.io/npm/v/@adonisjs/logger.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/@adonisjs/logger "npm" | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[license-url]: LICENSE.md | ||
[license-image]: https://img.shields.io/aur/license/pac.svg?style=for-the-badge | ||
[license-image]: https://img.shields.io/npm/l/@adonisjs/logger?color=blueviolet&style=for-the-badge | ||
[license-url]: LICENSE.md "license" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22657
497
156
+ Addedabstract-logging@2.0.1(transitive)
+ Addedts-essentials@4.0.0(transitive)
- Removedabstract-logging@1.0.0(transitive)
- Removedts-essentials@3.0.5(transitive)
Updated@types/pino@^5.15.0
Updatedabstract-logging@^2.0.0
Updatedpino@^5.15.0
Updatedts-essentials@^4.0.0