Socket
Socket
Sign inDemoInstall

@tsed/logger

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsed/logger - npm Package Compare versions

Comparing version 5.17.0 to 6.0.0

10

lib/appenders/class/BaseAppender.d.ts

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

/**
* @module appenders
*/
/** */
import { LogEvent } from "../../core/LogEvent";
import { IAppenderConfiguration, PartialAppenderConfiguration } from "../interfaces/AppenderConfiguration";
import { AppenderConfiguration, PartialAppenderConfiguration } from "../interfaces/AppenderConfiguration";
export interface IAppenderOptions {

@@ -56,4 +52,4 @@ name: string;

[key: string]: any;
constructor(_config: IAppenderConfiguration);
get config(): IAppenderConfiguration;
constructor(_config: AppenderConfiguration);
get config(): AppenderConfiguration;
configure(config: PartialAppenderConfiguration): this;

@@ -60,0 +56,0 @@ /**

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

/**
* @module appenders
*/
/** */
import { LogEvent } from "../../core/LogEvent";

@@ -6,0 +2,0 @@ import { BaseAppender } from "../class/BaseAppender";

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

/**
* @module appenders
*/
/** */
import { LogEvent } from "../../core/LogEvent";

@@ -6,0 +2,0 @@ import { BaseAppender } from "../class/BaseAppender";

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

/**
* @module appenders
*/
/** */
import { LogEvent } from "../../core/LogEvent";

@@ -6,0 +2,0 @@ import { BaseAppender } from "../class/BaseAppender";

export * from "./components/ConsoleAppender";
export * from "./components/FileAppender";
export * from "./components/StderrAppender";

@@ -4,0 +3,0 @@ export * from "./components/StdoutAppender";

@@ -1,10 +0,6 @@

/**
* @module appenders
*/
/** */
import { IBasicLayoutConfiguration } from "../../layouts/interfaces/BasicLayoutConfiguration";
export interface IAppenderConfiguration {
import { BasicLayoutConfiguration } from "../../layouts/interfaces/BasicLayoutConfiguration";
export interface AppenderConfiguration {
type: string;
filename?: string;
layout?: IBasicLayoutConfiguration;
layout?: BasicLayoutConfiguration;
maxLogSize?: number;

@@ -19,2 +15,2 @@ pattern?: string;

};
export declare type PartialAppenderConfiguration = Partial<IAppenderConfiguration>;
export declare type PartialAppenderConfiguration = Partial<AppenderConfiguration>;

@@ -1,9 +0,5 @@

/**
* @module appenders
*/
/** */
export interface IAppenderProvider {
export interface AppenderProvider {
provide: any;
instance?: any;
}
export declare const AppendersRegistry: Map<string, IAppenderProvider>;
export declare const AppendersRegistry: Map<string, AppenderProvider>;

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

/**
* @module core
*/
/** */
export * from "./LogEvent";
export * from "./LogLevel";
export * from "./LogContext";

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

/**
* @module core
*/
/** */
export declare class LogLevel {

@@ -6,0 +2,0 @@ readonly level: number;

var tslib = require('tslib');
var Path = require('path');
var Util = require('util');
var Os = require('os');
var Util = require('util');

@@ -26,5 +25,4 @@ function _interopNamespace(e) {

var Path__namespace = /*#__PURE__*/_interopNamespace(Path);
var Util__namespace = /*#__PURE__*/_interopNamespace(Util);
var Os__namespace = /*#__PURE__*/_interopNamespace(Os);
var Util__namespace = /*#__PURE__*/_interopNamespace(Util);

@@ -55,3 +53,3 @@ const AppendersRegistry = new Map();

* @param name Required. The configuration of the element to return from the Map object.
* @returns {ILoggerAppender}
* @returns {LoggerAppender}
*/

@@ -327,7 +325,2 @@

/**
* @module core
*/
/** */
class LogLevel {

@@ -620,5 +613,2 @@ constructor(level, levelStr) {

/**
* @module appenders
*/
function Appender(options) {

@@ -771,163 +761,2 @@ return target => {

/**
* @module appenders
*/
const streams = require("streamroller");
const eol$1 = Os__namespace.EOL || "\n";
/**
* ## File Appender
*
* The file appender writes log events to a file. It supports an optional maximum file size, and will keep a configurable number of backups. When using the file appender, you should also call `logger.shutdown()` when your application terminates, to ensure that any remaining asynchronous writes have finished. Although the file appender uses the streamroller library, this is included as a dependency of ts-log-debug so you do not need to include it yourself.
*
* ## Configuration
*
* * type - "file"
* * filename - string - the path of the file where you want your logs written.
* * maxLogSize - integer (optional) - the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
* * backups - integer (optional, default value = 5) - the number of old log files to keep during log rolling.
* * layout - (optional, defaults to basic layout) - see layouts
*
* Any other configuration parameters will be passed to the underlying streamroller implementation (see also node.js core file streams):
*
* * encoding - string (default “utf-8”)
* * mode - integer (default 0644)
* * flags - string (default ‘a’)
* * compress - boolean (default false) - compress the backup files during rolling (backup files will have .gz extension)
*
* ## Example
*
* ```typescript
* import {Logger} from "@tsed/logger";
*
* const logger = new Logger("loggerName");
*
* logger.appenders.set("log-file", {
* type: "file",
* filename: "all-the-logs.log"
* });
* logger.debug('I will be logged in all-the-logs.log');
* ```
* > This example will result in a single log file (all-the-logs.log) containing the log messages.
*
* ## Example with log rolling (and compressed backups)
*
* ```typescript
* import {Logger} from "@tsed/logger";
*
* const logger = new Logger("loggerName");
*
* logger.appenders.set("log-file2", {
* type: "file",
* filename: "all-the-logs.log",
* maxLogSize: 10485760,
* backups: 3,
* compress: true
* });
* logger.debug('I will be logged in all-the-logs.log');
* ```
*
* :::
* This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on.
* :::
*
* ## Example with date rolling
*
* ```typescript
* import { Logger } from "@tsed/logger";
* export const logger = new Logger("Log Example");
*
* logger.appenders
* .set('file', {
* type: 'file',
* filename: `${__dirname}/../logs/myfile.log`,
* pattern: '.yyyy-MM-dd'
* });
* ```
*
*/
exports.FileAppender = class FileAppender extends BaseAppender {
/**
*
*/
reopen() {
return this.shutdown().then(() => {
this.build();
});
}
/**
*
*/
shutdown() {
process.removeListener("SIGHUP", this.listener);
return new Promise((resolve, reject) => {
this.writer.write("", "utf-8", () => {
this.writer.end(resolve);
});
});
}
/**
*
* @param loggingEvent
*/
write(loggingEvent) {
this.writer.write(this.layout(loggingEvent, this.config.timezoneOffset) + eol$1, "utf8");
}
build() {
let {
filename: file,
maxLogSize: logSize,
backups: numBackups,
pattern
} = this.config;
file = Path__namespace.normalize(file);
numBackups = numBackups === undefined ? 5 : numBackups; // there has to be at least one backup if logSize has been specified
numBackups = numBackups === 0 ? 1 : numBackups;
this.writer = this.openTheStream(file, logSize, numBackups, pattern, this.config); // On SIGHUP, close and reopen all files. This allows this appender to work with
// logrotate. Note that if you are using logrotate, you should not set
// `logSize`.
this.listener = () => this.reopen();
process.on("SIGHUP", this.listener);
}
/**
*
* @param file
* @param fileSize
* @param numFiles
* @param options
* @returns {streams.RollingFileStream}
*/
openTheStream(file, fileSize, numFiles, pattern, options) {
let stream = null;
if (pattern) {
stream = new streams.DateRollingFileStream(file, pattern, options);
} else {
stream = new streams.RollingFileStream(file, fileSize, numFiles, options);
}
stream.on("error", err => {
console.error("FileAppender - Writing to file %s, error happened ", file, err);
});
return stream;
}
};
exports.FileAppender = tslib.__decorate([Appender({
name: "file",
defaultLayout: "basic"
})], exports.FileAppender);
/**
* ## Standard Error Appender

@@ -934,0 +763,0 @@ *

import { __decorate, __metadata } from 'tslib';
import * as Path from 'path';
import * as Util from 'util';
import * as Os from 'os';
import * as Util from 'util';

@@ -30,3 +29,3 @@ const AppendersRegistry = new Map();

* @param name Required. The configuration of the element to return from the Map object.
* @returns {ILoggerAppender}
* @returns {LoggerAppender}
*/

@@ -302,7 +301,2 @@

/**
* @module core
*/
/** */
class LogLevel {

@@ -595,5 +589,2 @@ constructor(level, levelStr) {

/**
* @module appenders
*/
function Appender(options) {

@@ -746,163 +737,2 @@ return target => {

/**
* @module appenders
*/
const streams = require("streamroller");
const eol$1 = Os.EOL || "\n";
/**
* ## File Appender
*
* The file appender writes log events to a file. It supports an optional maximum file size, and will keep a configurable number of backups. When using the file appender, you should also call `logger.shutdown()` when your application terminates, to ensure that any remaining asynchronous writes have finished. Although the file appender uses the streamroller library, this is included as a dependency of ts-log-debug so you do not need to include it yourself.
*
* ## Configuration
*
* * type - "file"
* * filename - string - the path of the file where you want your logs written.
* * maxLogSize - integer (optional) - the maximum size (in bytes) for the log file. If not specified, then no log rolling will happen.
* * backups - integer (optional, default value = 5) - the number of old log files to keep during log rolling.
* * layout - (optional, defaults to basic layout) - see layouts
*
* Any other configuration parameters will be passed to the underlying streamroller implementation (see also node.js core file streams):
*
* * encoding - string (default “utf-8”)
* * mode - integer (default 0644)
* * flags - string (default ‘a’)
* * compress - boolean (default false) - compress the backup files during rolling (backup files will have .gz extension)
*
* ## Example
*
* ```typescript
* import {Logger} from "@tsed/logger";
*
* const logger = new Logger("loggerName");
*
* logger.appenders.set("log-file", {
* type: "file",
* filename: "all-the-logs.log"
* });
* logger.debug('I will be logged in all-the-logs.log');
* ```
* > This example will result in a single log file (all-the-logs.log) containing the log messages.
*
* ## Example with log rolling (and compressed backups)
*
* ```typescript
* import {Logger} from "@tsed/logger";
*
* const logger = new Logger("loggerName");
*
* logger.appenders.set("log-file2", {
* type: "file",
* filename: "all-the-logs.log",
* maxLogSize: 10485760,
* backups: 3,
* compress: true
* });
* logger.debug('I will be logged in all-the-logs.log');
* ```
*
* :::
* This will result in one current log file (all-the-logs.log). When that reaches 10Mb in size, it will be renamed and compressed to all-the-logs.log.1.gz and a new file opened called all-the-logs.log. When all-the-logs.log reaches 10Mb again, then all-the-logs.log.1.gz will be renamed to all-the-logs.log.2.gz, and so on.
* :::
*
* ## Example with date rolling
*
* ```typescript
* import { Logger } from "@tsed/logger";
* export const logger = new Logger("Log Example");
*
* logger.appenders
* .set('file', {
* type: 'file',
* filename: `${__dirname}/../logs/myfile.log`,
* pattern: '.yyyy-MM-dd'
* });
* ```
*
*/
let FileAppender = class FileAppender extends BaseAppender {
/**
*
*/
reopen() {
return this.shutdown().then(() => {
this.build();
});
}
/**
*
*/
shutdown() {
process.removeListener("SIGHUP", this.listener);
return new Promise((resolve, reject) => {
this.writer.write("", "utf-8", () => {
this.writer.end(resolve);
});
});
}
/**
*
* @param loggingEvent
*/
write(loggingEvent) {
this.writer.write(this.layout(loggingEvent, this.config.timezoneOffset) + eol$1, "utf8");
}
build() {
let {
filename: file,
maxLogSize: logSize,
backups: numBackups,
pattern
} = this.config;
file = Path.normalize(file);
numBackups = numBackups === undefined ? 5 : numBackups; // there has to be at least one backup if logSize has been specified
numBackups = numBackups === 0 ? 1 : numBackups;
this.writer = this.openTheStream(file, logSize, numBackups, pattern, this.config); // On SIGHUP, close and reopen all files. This allows this appender to work with
// logrotate. Note that if you are using logrotate, you should not set
// `logSize`.
this.listener = () => this.reopen();
process.on("SIGHUP", this.listener);
}
/**
*
* @param file
* @param fileSize
* @param numFiles
* @param options
* @returns {streams.RollingFileStream}
*/
openTheStream(file, fileSize, numFiles, pattern, options) {
let stream = null;
if (pattern) {
stream = new streams.DateRollingFileStream(file, pattern, options);
} else {
stream = new streams.RollingFileStream(file, fileSize, numFiles, options);
}
stream.on("error", err => {
console.error("FileAppender - Writing to file %s, error happened ", file, err);
});
return stream;
}
};
FileAppender = __decorate([Appender({
name: "file",
defaultLayout: "basic"
})], FileAppender);
/**
* ## Standard Error Appender

@@ -1498,3 +1328,3 @@ *

export { $log, Appender, BaseAppender, BaseLayout, BasicLayout, ColoredLayout, ConsoleAppender, DummyLayout, FileAppender, JsonLayout, LOG_COLORS, Layout, Layouts, LogContext, LogEvent, LogLevel, Logger, LoggerAppenders, MessagePassThroughLayout, PatternLayout, StderrAppender, StdoutAppender, colorize, colorizeEnd, colorizeStart, levels, removeColors };
export { $log, Appender, BaseAppender, BaseLayout, BasicLayout, ColoredLayout, ConsoleAppender, DummyLayout, JsonLayout, LOG_COLORS, Layout, Layouts, LogContext, LogEvent, LogLevel, Logger, LoggerAppenders, MessagePassThroughLayout, PatternLayout, StderrAppender, StdoutAppender, colorize, colorizeEnd, colorizeStart, levels, removeColors };
//# sourceMappingURL=index.modern.js.map
import { LogEvent } from "../../core/LogEvent";
import { IBasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
import { BasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
export declare abstract class BaseLayout {
protected config: IBasicLayoutConfiguration;
constructor(config: IBasicLayoutConfiguration);
protected config: BasicLayoutConfiguration;
constructor(config: BasicLayoutConfiguration);
abstract transform(loggingEvent: LogEvent, timezoneOffset?: number): string;
}

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

import { IBasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
import { BasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
import { BaseLayout } from "./BaseLayout";
export declare class Layouts {
static get(name: string | any, config: IBasicLayoutConfiguration): BaseLayout;
static get(name: string | any, config: BasicLayoutConfiguration): BaseLayout;
}
import { BaseLayout } from "../class/BaseLayout";
import { LogEvent } from "../../core/LogEvent";
import { IBasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
import { BasicLayoutConfiguration } from "../interfaces/BasicLayoutConfiguration";
/**

@@ -39,3 +39,3 @@ * PatternLayout

#private;
constructor(config: IBasicLayoutConfiguration);
constructor(config: BasicLayoutConfiguration);
/**

@@ -42,0 +42,0 @@ *

@@ -6,3 +6,3 @@ import { LogEvent } from "../../core/LogEvent";

}
export interface IBasicLayoutConfiguration {
export interface BasicLayoutConfiguration {
type: string;

@@ -9,0 +9,0 @@ pattern?: string;

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

export interface ILayoutProvider {
export interface LayoutProvider {
provide: any;
instance?: any;
}
export declare const LayoutsRegistry: Map<string, ILayoutProvider>;
export declare const LayoutsRegistry: Map<string, LayoutProvider>;
import { BaseAppender } from "../../appenders/class/BaseAppender";
import { LogLevel } from "../../core/LogLevel";
import { IAppenderConfiguration } from "../../appenders/interfaces/AppenderConfiguration";
export interface ILoggerAppender {
import { AppenderConfiguration } from "../../appenders/interfaces/AppenderConfiguration";
export interface LoggerAppender {
name: string;
instance: any;
config: IAppenderConfiguration;
config: AppenderConfiguration;
}

@@ -22,5 +22,5 @@ export declare class LoggerAppenders {

* @param name Required. The configuration of the element to return from the Map object.
* @returns {ILoggerAppender}
* @returns {LoggerAppender}
*/
get(name: string): ILoggerAppender;
get(name: string): LoggerAppender;
/**

@@ -32,3 +32,3 @@ * The `set()` method adds or updates an element with a specified key and value to a loggerAppenders object.

*/
set(name: string, config: IAppenderConfiguration): LoggerAppenders;
set(name: string, config: AppenderConfiguration): LoggerAppenders;
/**

@@ -49,3 +49,3 @@ * Remove all configuration that match with the `name`.

*/
forEach(callback: (value: ILoggerAppender, key: string, map: Map<string, ILoggerAppender>) => void, thisArg?: any): void;
forEach(callback: (value: LoggerAppender, key: string, map: Map<string, LoggerAppender>) => void, thisArg?: any): void;
/**

@@ -52,0 +52,0 @@ *

{
"name": "@tsed/logger",
"version": "5.17.0",
"version": "6.0.0",
"description": "A multi channel logger written in TypeScript.",

@@ -33,5 +33,3 @@ "private": false,

"date-format": "^3.0.0",
"lodash": "^4.17.21",
"semver": "^7.3.2",
"streamroller": "^1.0.3",
"tslib": "2.3.0"

@@ -38,0 +36,0 @@ },

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