New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zodash/logger

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zodash/logger - npm Package Compare versions

Comparing version 0.2.16 to 0.2.17

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [0.2.17](https://github.com/zcorky/zodash/compare/@zodash/logger@0.2.16...@zodash/logger@0.2.17) (2021-08-12)
**Note:** Version bump only for package @zodash/logger
## [0.2.16](https://github.com/zcorky/zodash/compare/@zodash/logger@0.2.15...@zodash/logger@0.2.16) (2021-05-03)

@@ -8,0 +16,0 @@

@@ -39,2 +39,5 @@ import { Onion, Context, Middleware } from '@zodash/onion';

static setDisable(fn: () => boolean): void;
private logDir;
private logDate;
private logFiles;
constructor(name: string, options?: Options);

@@ -50,4 +53,7 @@ private useDefaulEngine;

debug(message: string, ...args: any[]): void;
getLogMessage(datetime: Moment, message: string[], level: LogLevel): string | any[];
private getLogFile;
setLogDir(logDir: string): void;
}
export declare function getLogger(name: string, options?: Options): Logger;
export {};

@@ -48,2 +48,31 @@ "use strict";

this.options = options;
this.logDir = null; // '/tmp/zodash.log';
this.logDate = moment_1.moment().format('YYYY-MM-DD');
this.logFiles = {};
this.getLogFile = async function (level) {
// eslint-disable-next-line
const fs = require('fs');
const today = moment_1.moment().format('YYYY-MM-DD');
const getLogeFileStream = () => {
return fs.createWriteStream(`${this.logDir}/${level}.${this.logDate}.log`, { flags: 'a' });
};
if (!this.logDir) {
this.logDir = process.env.LOG_DIR || this.logDir;
if (!fs.existsSync(this.logDir)) {
await fs.promises.mkdir(this.logDir);
}
}
if (!this.logFiles[level]) {
this.logFiles[level] = getLogeFileStream();
}
else if (this.logDate !== today) {
// for safe, close old fs handler
if (this.logFiles[level]) {
this.logFiles[level].close();
}
this.logDate = today;
this.logFiles[level] = getLogeFileStream();
}
return this.logFiles[level];
};
this.options = options || {};

@@ -150,2 +179,17 @@ this.use(this.useDisable());

}
getLogMessage(datetime, message, level) {
return formatMessage(this.name, datetime, message, level);
}
setLogDir(logDir) {
this.logDir = logDir;
this.use(async (ctx, next) => {
await next();
const logfile = await this.getLogFile(ctx.input.level);
const logfileAll = await this.getLogFile('all');
// @TODO
const message = `[${ctx.input.datetime.format('YYYY-MM-DD HH:mm:ss.SSS')}] ${ctx.input.level.toUpperCase()} - ${ctx.input.message}`;
logfile.write(message + '\n');
logfileAll.write(message + '\n');
});
}
}

@@ -152,0 +196,0 @@ exports.Logger = Logger;

4

package.json
{
"name": "@zodash/logger",
"version": "0.2.16",
"version": "0.2.17",
"description": "simple logger model",

@@ -71,3 +71,3 @@ "keywords": [

},
"gitHead": "904ffa5f78d9aae6d39c9946cf5c36c7a4bcb60b"
"gitHead": "fc31d114f3909697b99432c35ec159ee25f23d84"
}
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