Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

klg-logger

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

klg-logger - npm Package Compare versions

Comparing version 2.0.1-0 to 2.0.1-1

27

dist/Logger.d.ts

@@ -1,6 +0,27 @@

/// <reference path="../node_modules/tracer/index.d.ts" />
export * from 'tracer';
import { Tracer } from 'tracer';
export declare type KlgTransportFunction = (data: Tracer.LogOutput) => void;
/**
* Tracer 的 tsd 文件把 transport 参数类型搞错了,这里更正一下,已经 PR
* typescript 不支持 overwrite interface property,所以这里只能重新定义一遍了
*/
export interface LoggerConfig {
format?: string;
dateformat?: string;
filters?: Tracer.FilterFunction[];
level?: string;
methods?: string[];
stackIndex?: number;
inspectOpt?: {
showHidden: boolean;
depth: number;
};
preprocess?(data: Tracer.LogOutput): void;
transport?: KlgTransportFunction | KlgTransportFunction[];
}
/**
* console 是一个没有 constructor 属性的 function,不能直接 class Logger extends console
* 所以需要通过 Function 来做一个桥接,在 Function 的 constructor 中 return console 实例
*/
export declare class Logger extends Function implements Tracer.Logger {
constructor(config?: any);
constructor(config?: LoggerConfig);
debug(...args: any[]): Tracer.LogOutput;

@@ -7,0 +28,0 @@ err(...args: any[]): Tracer.LogOutput;

9

dist/Logger.js
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
///<reference path="../node_modules/tracer/index.d.ts"/>
__export(require("tracer"));
const tracer_1 = require("tracer");
/**
* console 是一个没有 constructor 属性的 function,不能直接 class Logger extends console
* 所以需要通过 Function 来做一个桥接,在 Function 的 constructor 中 return console 实例
*/
class Logger extends Function {

@@ -10,0 +9,0 @@ constructor(config) {

{
"name": "klg-logger",
"version": "2.0.1-0",
"version": "2.0.1-1",
"description": "log 工具,基于 tracer,简单,可以显示 log 的位置",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import * as assert from 'power-assert'
import {Logger, Tracer} from './Logger'
import {Logger} from './Logger'

@@ -10,3 +10,3 @@ describe('logger ts test', async function () {

stackIndex: 1,
transport: function (data: Tracer.LogOutput) {
transport: function (data) {
console.log('data', data);

@@ -13,0 +13,0 @@ assert(data)

@@ -1,11 +0,38 @@

///<reference path="../node_modules/tracer/index.d.ts"/>
export * from 'tracer'
import {console, Tracer} from 'tracer'
export type KlgTransportFunction = (data: Tracer.LogOutput) => void
/**
* Tracer 的 tsd 文件把 transport 参数类型搞错了,这里更正一下,已经 PR
* typescript 不支持 overwrite interface property,所以这里只能重新定义一遍了
*/
export interface LoggerConfig {
format?: string
dateformat?: string
filters?: Tracer.FilterFunction[]
level?: string
methods?: string[]
/* get the specified index of stack as file information. It is userful for development package. */
stackIndex?: number
inspectOpt?: {
/* if true then the object's non-enumerable properties will be shown too. Defaults to false */
showHidden: boolean,
depth: number
}
preprocess? (data: Tracer.LogOutput): void
transport?: KlgTransportFunction | KlgTransportFunction[]
}
/**
* console 是一个没有 constructor 属性的 function,不能直接 class Logger extends console
* 所以需要通过 Function 来做一个桥接,在 Function 的 constructor 中 return console 实例
*/
export class Logger extends Function implements Tracer.Logger {
constructor (config?) {
constructor (config?: LoggerConfig) {
super()
Object.setPrototypeOf(console, Logger.prototype)
const instance = console(config) as Logger
const instance = console(config as any) as Logger
instance.err = instance.error

@@ -17,3 +44,3 @@ return instance

debug (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}

@@ -26,24 +53,24 @@

error (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
fatal (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
info (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
log (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
trace (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
warn (...args: any[]): Tracer.LogOutput {
return undefined;
return undefined
}
}
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