Socket
Socket
Sign inDemoInstall

@spinajs/log

Package Overview
Dependencies
Maintainers
1
Versions
277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/log - npm Package Compare versions

Comparing version 1.2.75 to 1.2.79

5

lib/bootstrap.js

@@ -8,2 +8,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,3 +17,3 @@ exports.LogBotstrapper = void 0;

const log_1 = require("./log");
const log_configuration_1 = require("./schemas/log.configuration");
const log_configuration_1 = __importDefault(require("./schemas/log.configuration"));
let LogBotstrapper = class LogBotstrapper extends di_1.Bootstrapper {

@@ -17,0 +20,0 @@ bootstrap() {

6

lib/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -11,2 +11,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var Log_1;

@@ -18,6 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

/* eslint-disable @typescript-eslint/no-unsafe-argument */
const types_1 = require("@spinajs/configuration/lib/types");
const configuration_1 = require("@spinajs/configuration");
const di_1 = require("@spinajs/di");
const log_common_1 = require("@spinajs/log-common");
const globToRegexp = require("glob-to-regexp");
const glob_to_regexp_1 = __importDefault(require("glob-to-regexp"));
const exceptions_1 = require("@spinajs/exceptions");

@@ -73,3 +76,3 @@ function wrapWrite(level) {

resolve() {
const config = this.Container.get(types_1.Configuration);
const config = this.Container.get(configuration_1.Configuration);
if (!config) {

@@ -147,3 +150,5 @@ throw new Error(`Configuration module is not avaible. Please resolve configuration module before any logging can occur`);

this.Rules = this.Options.rules.filter((r) => {
return globToRegexp(r.name).test(this.Name);
const g = (0, glob_to_regexp_1.default)(r.name);
// BUG: g.test throws vscode err ?
return g.test(this.Name);
});

@@ -150,0 +155,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -8,2 +24,9 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,3 +38,3 @@ exports.ColoredConsoleTarget = exports.DEFAULT_THEME = void 0;

const __1 = require("..");
const colors = require("colors/safe");
const colors = __importStar(require("colors/safe"));
const configuration_1 = require("@spinajs/configuration");

@@ -18,0 +41,0 @@ exports.DEFAULT_THEME = {

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

/// <reference types="node" />
import { LogTarget } from "./LogTarget";
import { IFileTargetOptions, ILogEntry } from "@spinajs/log-common";
import * as fs from "fs";
import { Job } from "node-schedule";

@@ -15,9 +17,11 @@ export declare class FileTarget extends LogTarget<IFileTargetOptions> {

protected BufferSize: number;
protected FlushTimeout: NodeJS.Timeout;
protected Buffer: any[];
protected WriteStream: fs.WriteStream;
resolve(): void;
write(data: ILogEntry): Promise<void>;
protected archive(): void;
protected flush(): void;
private rotate;
private initialize;
private reopenStream;
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -8,2 +24,9 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,10 +37,11 @@ exports.FileTarget = void 0;

const LogTarget_1 = require("./LogTarget");
const fs = require("fs");
const path = require("path");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const node_schedule_1 = require("node-schedule");
const exceptions_1 = require("@spinajs/exceptions");
const os_1 = require("os");
const glob = require("glob");
const zlib = require("zlib");
const glob = __importStar(require("glob"));
const zlib = __importStar(require("zlib"));
const configuration_1 = require("@spinajs/configuration");
const console_1 = require("console");
let FileTarget = class FileTarget extends LogTarget_1.LogTarget {

@@ -39,5 +63,2 @@ constructor() {

this.rotate();
process.on("exit", () => {
this.flush();
});
super.resolve();

@@ -50,7 +71,13 @@ }

const result = (0, configuration_1.format)(data.Variables, this.Options.layout) + os_1.EOL;
const bytes = Buffer.byteLength(result);
this.BufferSize += bytes;
this.Buffer.push(result);
if (this.BufferSize > this.Options.options.bufferSize) {
this.flush();
this.CurrentFileSize += Buffer.byteLength(result);
(0, console_1.assert)(this.WriteStream, "write stream is not created");
const ok = this.WriteStream.write(result, (err) => {
if (err) {
console.debug(`Cannot write to log stream at path ${this.LogPath}`);
}
});
if (!ok) {
this.WriteStream.once("drain", () => {
void this.write(data);
});
}

@@ -74,3 +101,2 @@ if (this.CurrentFileSize > this.Options.options.maxSize) {

const archPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}`);
this.flush();
if (!fs.existsSync(this.LogPath)) {

@@ -103,13 +129,2 @@ return;

}
flush() {
if (this.HasError || this.BufferSize === 0) {
return;
}
const fd = fs.openSync(this.LogPath, "a");
fs.writeFileSync(fd, this.Buffer.join());
fs.closeSync(fd);
this.CurrentFileSize += this.BufferSize;
this.Buffer = [];
this.BufferSize = 0;
}
rotate() {

@@ -123,3 +138,2 @@ if (this.Options.options.rotate) {

initialize() {
this.flush();
this.CurrentFileSize = 0;

@@ -144,13 +158,26 @@ this.LogDirPath = path.dirname(path.resolve((0, configuration_1.format)(null, this.Options.options.path)));

}
if (fs.existsSync(this.LogPath)) {
const { size } = fs.statSync(this.LogPath);
this.CurrentFileSize = size;
this.reopenStream();
}
reopenStream() {
if (this.WriteStream) {
this.WriteStream.removeAllListeners();
this.WriteStream.close((err) => {
console.debug(`Cannot close log write stream ${this.LogPath}, reason: ${err.message}`);
});
this.WriteStream = null;
}
if (this.Options.options.flushTimeout !== 0) {
setTimeout(() => {
this.flush();
}, this.Options.options.flushTimeout);
}
this.HasError = false;
this.Error = null;
this.WriteStream = fs.createWriteStream(this.LogPath, {
flags: "a",
encoding: "utf-8",
});
this.WriteStream.on("open", () => {
console.debug(`Opend log write stream at ${this.LogPath}`);
});
this.WriteStream.on("error", (err) => {
console.debug(`Cannot create log file write steram at path ${this.LogPath}, reason: ${err.message}`);
this.reopenStream();
});
this.WriteStream.on("close", () => {
console.debug(`Closed log write stream at ${this.LogPath}`);
});
}

@@ -157,0 +184,0 @@ };

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogTarget = void 0;
const di_1 = require("@spinajs/di");
const _ = require("lodash");
const _ = __importStar(require("lodash"));
class LogTarget extends di_1.SyncModule {

@@ -7,0 +30,0 @@ constructor(options) {

{
"name": "@spinajs/log",
"version": "1.2.75",
"version": "1.2.79",
"description": "Log lib for all spinejs related libs",

@@ -29,6 +29,6 @@ "main": "lib/index.js",

"dependencies": {
"@spinajs/configuration": "^1.2.71",
"@spinajs/di": "^1.2.68",
"@spinajs/exceptions": "^1.2.7",
"@spinajs/log-common": "^1.2.60",
"@spinajs/configuration": "^1.2.79",
"@spinajs/di": "^1.2.79",
"@spinajs/exceptions": "^1.2.79",
"@spinajs/log-common": "^1.2.79",
"ajv": "^8.8.2",

@@ -45,3 +45,3 @@ "colors": "^1.4.0",

},
"gitHead": "a50aef463274b1217b09fb37307d2db98d22c209"
"gitHead": "ae595f5daffb88372496b6e5bf38973f07e33683"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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