@politie/informant
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -256,7 +256,14 @@ 'use strict'; | ||
/** | ||
* Ensures the provided handler only receives records for the logger with the given name or any of its children. | ||
* Ensures the provided handler only receives records for: | ||
* * the logger with the given name or any of its children, if provided with a string | ||
* OR | ||
* * the logger(s) matching the given regular expression | ||
*/ | ||
function forLogger(name, handler) { | ||
var nameWithDot = name + '.'; | ||
return function (record) { return (record.logger === name || record.logger.startsWith(nameWithDot)) && handler(record); }; | ||
if (typeof name === 'string') { | ||
return function (record) { return (record.logger === name || record.logger.startsWith(name + '.')) && handler(record); }; | ||
} | ||
else { | ||
return function (record) { return name.test(record.logger) && handler(record); }; | ||
} | ||
} | ||
@@ -263,0 +270,0 @@ /** |
@@ -253,7 +253,14 @@ import { __extends, __assign } from 'tslib'; | ||
/** | ||
* Ensures the provided handler only receives records for the logger with the given name or any of its children. | ||
* Ensures the provided handler only receives records for: | ||
* * the logger with the given name or any of its children, if provided with a string | ||
* OR | ||
* * the logger(s) matching the given regular expression | ||
*/ | ||
function forLogger(name, handler) { | ||
var nameWithDot = name + '.'; | ||
return function (record) { return (record.logger === name || record.logger.startsWith(nameWithDot)) && handler(record); }; | ||
if (typeof name === 'string') { | ||
return function (record) { return (record.logger === name || record.logger.startsWith(name + '.')) && handler(record); }; | ||
} | ||
else { | ||
return function (record) { return name.test(record.logger) && handler(record); }; | ||
} | ||
} | ||
@@ -260,0 +267,0 @@ /** |
@@ -28,5 +28,8 @@ import { LogLevel } from './loglevel'; | ||
/** | ||
* Ensures the provided handler only receives records for the logger with the given name or any of its children. | ||
* Ensures the provided handler only receives records for: | ||
* * the logger with the given name or any of its children, if provided with a string | ||
* OR | ||
* * the logger(s) matching the given regular expression | ||
*/ | ||
export declare function forLogger(name: string, handler: LogHandler): LogHandler; | ||
export declare function forLogger(name: string | RegExp, handler: LogHandler): LogHandler; | ||
/** | ||
@@ -33,0 +36,0 @@ * Wraps the given handler s.t. the handler is called asynchronously in a future tick. |
{ | ||
"name": "@politie/informant", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Informant is a simple and fast logging library for Node.js and browser JavaScript applications.", | ||
@@ -5,0 +5,0 @@ "main": "dist/informant.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134941
1212