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

@niceties/logger

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@niceties/logger - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

appender-utils/package.json

2

dist/appender-utils.d.ts
import { Appender, LogMessage } from './types';
export declare function filterMessages<ErrorContext = Error>(predicate: (logMessage: LogMessage<ErrorContext>) => boolean, appender: Appender<ErrorContext>): Appender<ErrorContext>;
export declare function filterMessages<ErrorContext = Error, Api extends object = object>(predicate: (logMessage: LogMessage<ErrorContext>) => boolean, appender: Appender<ErrorContext>, api?: Api): Appender<ErrorContext> & Api;
export declare function combineAppenders<ErrorContext = Error>(...appenders: Appender<ErrorContext>[]): Appender<ErrorContext>;
import { Formatter, LogMessage } from './types';
export declare function createConsoleAppender(formatter: Formatter): ({ loglevel, action, message }: LogMessage) => void;
export declare function createConsoleAppender(formatter: Formatter): (message: LogMessage) => void;

@@ -1,2 +0,2 @@

!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerConsoleAppender={})}(this,(function(e){"use strict";e.createConsoleAppender=function(e){return function({loglevel:o,action:n,message:t}){console.log(e(t,o,2===n))}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerConsoleAppender={})}(this,(function(e){"use strict";e.createConsoleAppender=function(e){return function(n){console.log(e(n,2===n.action))}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=console-appender.umd.js.map

@@ -1,11 +0,7 @@

import { combineAppenders, filterMessages } from './appender-utils';
import { appender } from './details/global-appender';
import { Appender, LogLevel, LogMessage, Identity } from './types';
export declare function createLogger<ErrorContext = Error>(...args: [] | [string | Identity | undefined] | [string, Identity]): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & {
start(message: string, loglevel?: LogLevel | undefined): void;
update(message: string, loglevel?: LogLevel | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined): void;
withFilter(predicate: (logMessage: LogMessage<ErrorContext>) => boolean): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & any;
withAppender(appender: Appender<ErrorContext>): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & any;
start(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
update(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
appender(appender?: Appender<ErrorContext> | undefined): (message: LogMessage<ErrorContext>) => void;
};
export { appender, combineAppenders, filterMessages };

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).nicetiesLoggerCore={})}(this,(function(t){"use strict";function e(t,e){return function(n){t(n)&&e(n)}}function n(...t){return e=>{for(const n of t)try{n(e)}catch(t){}}}let o;let i=0;t.appender=function(t){return void 0!==t&&(o=t),o},t.combineAppenders=n,t.createLogger=function(...t){let u=1;const f=i++,{tag:l,parentId:r}=function(t){var e,n;let o,i;1===t.length?"string"==typeof t[0]?i=t[0]:o=null===(e=t[0])||void 0===e?void 0:e.id:2===t.length&&(i=t[0],o=null===(n=t[1])||void 0===n?void 0:n.id);return{parentId:o,tag:i}}(t);let c=t=>{o&&o(t)};const d=Object.assign((function(t,e=1,n){a(t,3,e,n)}),{start(t,e){void 0!==e&&(u=e),a(t,0,u)},update(t,e){a(t,1,null!=e?e:u)},finish(t,e){a(t,2,null!=e?e:u)},withFilter:t=>(c=e(t,c),d),withAppender:t=>(c=n(c,t),d)});Object.defineProperty(d,"id",{value:f,writable:!1});const s=new WeakRef(d);return d;function a(t,e,n,o){c({action:e,inputId:f,message:t,loglevel:n,tag:l,parentId:r,ref:s,context:o})}},t.filterMessages=e,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./global-appender")):"function"==typeof define&&define.amd?define(["exports","./global-appender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerCore={},e.nicetiesLoggerGlobalAppender)}(this,(function(e,t){"use strict";let n=0;e.createLogger=function(...e){let o=1;const i=n++,{tag:l,parentId:d}=function(e){var t,n;let o,i;1===e.length?"string"==typeof e[0]?i=e[0]:o=null===(t=e[0])||void 0===t?void 0:t.id:2===e.length&&(i=e[0],o=null===(n=e[1])||void 0===n?void 0:n.id);return{parentId:o,tag:i}}(e);let u=e=>{t.globalAppender&&t.globalAppender(e)};const a=Object.assign((function(e,t=1,n){r(e,3,t,n)}),{start(e,t,n){void 0!==t&&(o=t),r(e,0,o,n)},update(e,t,n){r(e,1,null!=t?t:o,n)},finish(e,t,n){r(e,2,null!=t?t:o,n)},appender:e=>(void 0!==e&&(u=e),u)});Object.defineProperty(a,"id",{value:i,writable:!1});const f=new WeakRef(a);return a;function r(e,t,n,o){u&&u({action:t,inputId:i,message:e,loglevel:n,tag:l,parentId:d,ref:f,context:o})}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=core.umd.js.map

@@ -5,1 +5,2 @@ import { ColorFormatters, Prefixes } from './types';

export declare const colors: ColorFormatters;
export declare function tagFactory(tag: string): string;

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

import { ColorFormatters, LogLevel, Prefixes } from './types';
export declare function createFormatter(colors: ColorFormatters, prefixes: Prefixes): (message: string, loglevel: LogLevel, usePrefix?: string | boolean | undefined, identation?: number) => string;
import { ColorFormatters, LogMessage, Prefixes } from './types';
export declare function createFormatter(colors: ColorFormatters, prefixes: Prefixes, tagFactory: (tag: string) => string): ({ loglevel, message, context, action, tag }: LogMessage, usePrefix?: string | boolean | undefined, identation?: number) => string;
export declare function terminalSupportsUnicode(): boolean;

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

import { createLogger, filterMessages, combineAppenders } from './core';
import { appender } from './details/global-appender';
import { createLogger } from './core';
import { appender } from './global-appender';
export * from './types';
export { createLogger, appender, filterMessages, combineAppenders };
export { createLogger, appender };

@@ -1,8 +0,4 @@

import { combineAppenders, filterMessages } from './appender-utils';
import { appender } from './details/global-appender';
import { Appender, LogLevel, LogMessage } from './types';
export declare function createLogger<ErrorContext = Error>(tag?: string): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & {
withFilter(predicate: (logMessage: LogMessage<ErrorContext>) => boolean): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & any;
withAppender(appender: Appender<ErrorContext>): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & any;
appender(appender?: Appender<ErrorContext> | undefined): (message: LogMessage<ErrorContext>) => void;
};
export { appender, combineAppenders, filterMessages };

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerSimple={})}(this,(function(e){"use strict";function t(e,t){return function(n){e(n)&&t(n)}}function n(...e){return t=>{for(const n of e)try{n(t)}catch(e){}}}let o;e.appender=function(e){return void 0!==e&&(o=e),o},e.combineAppenders=n,e.createLogger=function(e){let i=e=>{o&&o(e)};const f=Object.assign((function(t,n=1,o){i({action:3,message:t,loglevel:n,tag:e,context:o})}),{withFilter:e=>(i=t(e,i),f),withAppender:e=>(i=n(i,e),f)});return f},e.filterMessages=t,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./global-appender")):"function"==typeof define&&define.amd?define(["exports","./global-appender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerSimple={},e.nicetiesLoggerGlobalAppender)}(this,(function(e,t){"use strict";e.createLogger=function(e){let n=e=>{t.globalAppender&&t.globalAppender(e)};return Object.assign((function(t,o=1,i){n&&n({action:3,message:t,loglevel:o,tag:e,context:i})}),{appender:e=>(void 0!==e&&(n=e),n)})},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=simple.umd.js.map

@@ -21,2 +21,3 @@ export declare const enum LogLevel {

ref: WeakRef<never>;
context?: ErrorContext;
} | {

@@ -42,2 +43,11 @@ inputId?: number;

};
export declare type Formatter = (message: string, loglevel: LogLevel, usePrefix?: string | boolean, identation?: number) => string;
export declare type Formatter<ErrorContext = Error> = (message: LogMessage<ErrorContext>, usePrefix?: string | boolean, identation?: number) => string;
export declare type Logger<ErrorContext = Error> = (...args: [] | [string | Identity | undefined] | [string, Identity]) => ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & {
start(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
update(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
appender(appender?: Appender<ErrorContext>): (message: LogMessage<ErrorContext>) => void;
};
export declare type MinLogLevelApi = {
setMinLevel(logLevel: LogLevel): void;
};
{
"version": "1.0.4",
"version": "1.1.0",
"license": "MIT",

@@ -32,2 +32,10 @@ "name": "@niceties/logger",

"default": "./dist/format-utils.mjs"
},
"./global-appender": {
"require": "./dist/global-appender.cjs",
"default": "./dist/global-appender.mjs"
},
"./appender-utils": {
"require": "./dist/appender-utils.cjs",
"default": "./dist/appender-utils.mjs"
}

@@ -44,2 +52,4 @@ },

"console-appender",
"global-appender",
"appender-utils",
"format-utils",

@@ -60,2 +70,3 @@ "types",

"homepage": "https://github.com/kshutkin/niceties/blob/main/logger/README.md",
"readme": "REAMDE.md",
"scripts": {

@@ -76,11 +87,12 @@ "build": "rimraf ./dist && rollup -c",

"@semantic-release/release-notes-generator": "10.0.2",
"@types/jest": "27.0.2",
"@typescript-eslint/eslint-plugin": "5.3.0",
"@typescript-eslint/parser": "5.3.0",
"@types/jest": "27.0.3",
"@types/node": "17.0.5",
"@typescript-eslint/eslint-plugin": "5.8.1",
"@typescript-eslint/parser": "5.8.1",
"conventional-changelog-angular": "5.0.13",
"eslint": "8.1.0",
"jest": "27.3.1",
"eslint": "8.5.0",
"jest": "27.4.5",
"lodash": "4.17.21",
"rimraf": "3.0.2",
"rollup": "2.60.1",
"rollup": "2.62.0",
"rollup-plugin-preprocess": "0.0.4",

@@ -91,5 +103,6 @@ "rollup-plugin-terser": "7.0.2",

"semantic-release-monorepo": "7.0.5",
"ts-jest": "27.0.7",
"ts-jest": "27.1.2",
"tslib": "2.3.1",
"typescript": "4.4.x"
"typescript": "4.5.x",
"pkgbld": "1.1.1"
},

@@ -96,0 +109,0 @@ "dependencies": {

@@ -16,8 +16,2 @@ # Logger

```
yarn add @niceties/logger
```
or
```
npm install --save @niceties/logger

@@ -51,7 +45,7 @@ ```

```typescript
function createLogger<ErrorContext = Error>(...args: [] | [string | Identity] | [string, Identity]): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & {
start(message: string, loglevel?: LogLevel | undefined): void;
update(message: string, loglevel?: LogLevel | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined): void;
withAppender(appender: Appender<ErrorContext>): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & any;
function createLogger<ErrorContext = Error>(...args: [] | [string | Identity | undefined] | [string, Identity]): ((message: string, loglevel?: LogLevel, context?: ErrorContext | undefined) => void) & {
start(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
update(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
appender(appender?: Appender<ErrorContext> | undefined): (message: LogMessage<ErrorContext>) => void;
};

@@ -96,3 +90,3 @@ ```

```typescript
start(message: string, loglevel?: LogLevel | undefined): void;
start(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
```

@@ -103,3 +97,3 @@

```typescript
update(message: string, loglevel?: LogLevel | undefined): void;
update(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
```

@@ -110,3 +104,3 @@

```typescript
finish(message: string, loglevel?: LogLevel | undefined): void;
finish(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
```

@@ -117,14 +111,14 @@

```typescript
const log = createLogger()
.withAppender(someFancyAppender);
const logger = createLogger();
logger.appender(someFancyAppender);
```
Adds new appender for the specific inctance of logger. It is not mandatory to use the return value because no new instance of logger created and appender added to the existing instance.
Sets different appender for the specific instance of the logger.
```typescript
const log = createLogger()
.withFilter(predicate);
const logger = createLogger();
const appender = logger.appender();
```
Install filter on previosly installed appenders. It is not mandatory to use the return value because no new instance of logger created and filter added to the existing instance.
Returns current appender for the specific instance of the logger.

@@ -235,5 +229,5 @@ ## Log levels

Subpackage `'@niceties/logger/core'` exports `createLogger()` factory and `appender()`, `combineAppenders()`, `filterMessages()` functions.
Subpackage `'@niceties/logger/core'` exports `createLogger()` factory.
Subpackage `'@niceties/logger/simple'` exports `createLogger()` factory and `appender()`, `combineAppenders()`, `filterMessages()` function.
Subpackage `'@niceties/logger/simple'` exports `createLogger()` factory.

@@ -244,2 +238,6 @@ Subpackage `'@niceties/logger/console-appender'` exports `createConsoleAppender()` factory.

Subpackage `'@niceties/logger/global-appender'` exports `appender()` and `globalAppender`.
Subpackage `'@niceties/logger/appender-utils'` exports `combineAppenders()` and `filterMessages()`.
`simple` (default), `core` and `console-appender` exists as umd packages as well but probably require some effort to consume them.

@@ -246,0 +244,0 @@

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

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

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