Socket
Socket
Sign inDemoInstall

egg-logger

Package Overview
Dependencies
Maintainers
12
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-logger - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

2

index.d.ts

@@ -26,2 +26,3 @@ import { AsyncLocalStorage } from 'async_hooks';

contextFormatter?: (meta?: object) => string;
paddingMessageFormatter?: (ctx: object) => string;
jsonFile?: string;

@@ -178,2 +179,3 @@ outputJSON?: boolean;

contextFormatter?: (meta?: object) => string;
paddingMessageFormatter?: (ctx: object) => string;
json?: boolean;

@@ -180,0 +182,0 @@ encoding?: string;

6

lib/egg/logger.js

@@ -1,3 +0,1 @@

'use strict';
const path = require('path');

@@ -23,2 +21,4 @@ const Logger = require('../logger');

* - {Function} [formatter] - log format function
* - {Function} [contextFormatter] - ctx log format function
* - {Function} [paddingMessageFormatter] - padding message format function
* - {String} [jsonFile] - JSON log file

@@ -50,2 +50,3 @@ * - {Boolean} [outputJSON = false] - send JSON log or not

contextFormatter: this.options.contextFormatter,
paddingMessageFormatter: this.options.paddingMessageFormatter,
flushInterval: this.options.flushInterval,

@@ -75,2 +76,3 @@ eol: this.options.eol,

contextFormatter: this.options.contextFormatter,
formatPaddingMessage: this.options.formatPaddingMessage,
eol: this.options.eol,

@@ -77,0 +79,0 @@ localStorage: this.options.localStorage,

@@ -1,6 +0,4 @@

'use strict';
const util = require('util');
const depd = require('depd')('egg-logger');
const utils = require('./utils');
const depd = require('depd')('egg-logger');

@@ -7,0 +5,0 @@ /**

@@ -19,4 +19,5 @@ 'use strict';

* - {String} [level = NONE] - log level. ouput method must higher than this option. if level is `info`, `debug` will disabled
* - {Function} formatter - format function
* - {Function} contextFormatter - format function for context logger
* - {Function} [formatter] - format function
* - {Function} [contextFormatter] - format function for context logger
* - {Function} [paddingMessageFormatter] - format function for padding message
* - {Boolean} [json = false] - log format is json or not

@@ -23,0 +24,0 @@ * - {String} [encoding = utf8] - log encodeing, see {@link https://github.com/ashtuchkin/iconv-lite#supported-encodings}

@@ -111,3 +111,5 @@ 'use strict';

* - {Boolean} json
* - {Function} formatter
* - {Function} [formatter]
* - {Function} [contextFormatter]
* - {Function} [paddingMessageFormatter]
* @return {String|Buffer} formatted log string buffer

@@ -120,3 +122,15 @@ */

let formatter = meta.formatter || options.formatter;
if (meta.ctx && options.contextFormatter) formatter = options.contextFormatter;
if (meta.ctx) {
if (options.contextFormatter) {
formatter = options.contextFormatter;
if (!meta.paddingMessage) {
// should add paddingMessage to meta on custom contextFormatter
meta.paddingMessage = options.paddingMessageFormatter ?
options.paddingMessageFormatter(meta.ctx) : module.exports.defaultContextPaddingMessage(meta.ctx);
}
} else if (options.paddingMessageFormatter && !meta.paddingMessage) {
// use custom paddingMessageFormatter to format paddingMessage
meta.paddingMessage = options.paddingMessageFormatter(meta.ctx);
}
}

@@ -123,0 +137,0 @@ if (args[0] instanceof Error) {

{
"name": "egg-logger",
"version": "3.0.1",
"version": "3.1.0",
"description": "egg logger",
"main": "index.js",
"typings": "index.d.ts",
"types": "index.d.ts",
"files": [

@@ -15,3 +15,2 @@ "index.js",

"circular-json-for-egg": "^1.0.0",
"debug": "^4.3.4",
"depd": "^2.0.0",

@@ -28,6 +27,5 @@ "egg-errors": "^2.3.1",

"egg-bin": "^5.5.0",
"egg-ci": "^2.2.0",
"eslint": "^8.29.0",
"eslint-config-egg": "^12.1.0",
"git-contributor": "^1.0.10",
"git-contributor": "^2.0.0",
"koa": "^2.14.1",

@@ -37,2 +35,3 @@ "mm": "^3.2.1",

"ts-node": "^10.9.1",
"tsd": "^0.25.0",
"typescript": "^4.9.4"

@@ -48,2 +47,3 @@ },

"contributor": "git-contributor",
"tsd": "tsd",
"lint": "eslint .",

@@ -58,7 +58,3 @@ "test": "npm run lint -- --fix && npm run test-local",

},
"ci": {
"version": "14, 16, 18",
"os": "linux, macos"
},
"license": "MIT"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc