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

@stencila/logga

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stencila/logga - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

7

CHANGELOG.md

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

# [2.1.0](https://github.com/stencila/logga/compare/v2.0.0...v2.1.0) (2019-12-02)
### Features
* **Default handler:** Add showStack option ([0dc246e](https://github.com/stencila/logga/commit/0dc246e05627b9e93363b034dc6e487c7abc855f))
# [2.0.0](https://github.com/stencila/logga/compare/v1.4.1...v2.0.0) (2019-11-21)

@@ -2,0 +9,0 @@

2

dist/browser/index.js

@@ -6,4 +6,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"g5IB":[function(require,module,exports) {

var process = require("process");
var e=require("process");function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t=this&&this.__assign||function(){return(t=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},n=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),o=0;for(r=0;r<t;r++)for(var i=arguments[r],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n};Object.defineProperty(exports,"__esModule",{value:!0});var o,i,s="stencila:logga";if(void 0!==e&&(o={emit:e.emit,listeners:e.listeners,addListener:e.addListener,removeListener:e.removeListener,removeAllListeners:e.removeAllListeners}),"undefined"!=typeof window){var a=new Map;o={emit:function(e,r){window.dispatchEvent(new CustomEvent(e,{detail:r}))},listeners:function(){return Array.from(a.keys())},addListener:function(e,r){var t=function(e){return r(e.detail)};window.addEventListener(e,t),a.set(r,t)},removeListener:function(e,r){var t=a.get(r);void 0!==t&&(window.removeEventListener(e,t),a.delete(r))},removeAllListeners:function(e){Array.from(a.values()).map(function(r){window.removeEventListener(e,r)}),a.clear()}}}function v(e,t,a){var v="";"object"===r(e)&&void 0!==e.message?v=e.message:"string"==typeof e&&(v=e);var d={tag:t,level:a,message:v};if("object"===r(e)&&void 0!==e.stack)d.stack=e.stack;else if(a<=i.error){var l=new Error;if(void 0!==l.stack){var f=l.stack.split("\n");d.stack=n([f[0]],f.slice(3)).join("\n")}}o.emit(s,d)}function d(){return o.listeners(s)}function l(e,r){void 0===r&&(r={});var t=e,n=r.tags,i=r.maxLevel,a=r.messageRegex,v=r.func;return void 0===n&&void 0===i&&void 0===a&&void 0===v||(t=function(r){(void 0===n||n.includes(r.tag))&&(void 0!==i&&r.level>i||(void 0===a||a.test(r.message))&&(void 0===v||v(r))&&e(r))}),o.addListener(s,t),t}function f(e){o.removeListener(s,e)}function u(){o.removeAllListeners(s)}function c(e){u(),l(e)}!function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.info=2]="info",e[e.debug=3]="debug"}(i=exports.LogLevel||(exports.LogLevel={})),exports.handlers=d,exports.addHandler=l,exports.removeHandler=f,exports.removeHandlers=u,exports.replaceHandlers=c;var m=new Map;function p(r,n){var o=r.tag,s=r.level,a=r.message,v=r.stack;if(!(s>(void 0!==n&&void 0!==n.maxLevel?n.maxLevel:i.info))){var d=void 0!==n?n.throttle:void 0;if(void 0!==d){var l=(void 0!==d.signature?d.signature:"").replace(/\${tag}/,o).replace(/\${level}/,s.toString()).replace(/\${message}/,a),f=m.get(l);if(void 0!==f){var u=void 0!==d.duration?d.duration:1e3;if(Date.now()-f<u)return}m.set(l,Date.now())}var c="";if(void 0!==e&&void 0!==e.stderr&&!0!==e.stderr.isTTY)c=JSON.stringify(t({time:(new Date).toISOString()},r));else{var p=s<0?0:s>3?3:s,g=i[p].toUpperCase().padEnd(5," ");if("undefined"!=typeof window)c=g+" "+o+" "+a;else{c=["🚨","⚠","🛈","🐛"][p]+" "+["","","",""][p]+g+" "+o+" "+a}void 0!==v&&(c+="\n "+v)}console.error(c)}}function g(e){return{error:function(r){v(r,e,i.error)},warn:function(r){v(r,e,i.warn)},info:function(r){v(r,e,i.info)},debug:function(r){v(r,e,i.debug)}}}exports.defaultHandler=p,0===d().length&&l(p),exports.getLogger=g;
var e=require("process");function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t=this&&this.__assign||function(){return(t=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},n=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),o=0;for(r=0;r<t;r++)for(var i=arguments[r],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n};Object.defineProperty(exports,"__esModule",{value:!0});var o,i,s="stencila:logga";if(void 0!==e&&(o={emit:e.emit,listeners:e.listeners,addListener:e.addListener,removeListener:e.removeListener,removeAllListeners:e.removeAllListeners}),"undefined"!=typeof window){var a=new Map;o={emit:function(e,r){window.dispatchEvent(new CustomEvent(e,{detail:r}))},listeners:function(){return Array.from(a.keys())},addListener:function(e,r){var t=function(e){return r(e.detail)};window.addEventListener(e,t),a.set(r,t)},removeListener:function(e,r){var t=a.get(r);void 0!==t&&(window.removeEventListener(e,t),a.delete(r))},removeAllListeners:function(e){Array.from(a.values()).map(function(r){window.removeEventListener(e,r)}),a.clear()}}}function v(e,t,a){var v="";"object"===r(e)&&void 0!==e.message?v=e.message:"string"==typeof e&&(v=e);var d={tag:t,level:a,message:v};if("object"===r(e)&&void 0!==e.stack)d.stack=e.stack;else if(a<=i.error){var l=new Error;if(void 0!==l.stack){var f=l.stack.split("\n");d.stack=n([f[0]],f.slice(3)).join("\n")}}o.emit(s,d)}function d(){return o.listeners(s)}function l(e,r){void 0===r&&(r={});var t=e,n=r.tags,i=r.maxLevel,a=r.messageRegex,v=r.func;return void 0===n&&void 0===i&&void 0===a&&void 0===v||(t=function(r){(void 0===n||n.includes(r.tag))&&(void 0!==i&&r.level>i||(void 0===a||a.test(r.message))&&(void 0===v||v(r))&&e(r))}),o.addListener(s,t),t}function f(e){o.removeListener(s,e)}function u(){o.removeAllListeners(s)}function c(e){u(),l(e)}!function(e){e[e.error=0]="error",e[e.warn=1]="warn",e[e.info=2]="info",e[e.debug=3]="debug"}(i=exports.LogLevel||(exports.LogLevel={})),exports.handlers=d,exports.addHandler=l,exports.removeHandler=f,exports.removeHandlers=u,exports.replaceHandlers=c;var m=new Map;function p(r,n){void 0===n&&(n={});var o=r.tag,s=r.level,a=r.message,v=r.stack,d=n.maxLevel;if(!(s>(void 0===d?i.info:d))){var l=n.throttle;if(void 0!==l){var f=(void 0!==l.signature?l.signature:"").replace(/\${tag}/,o).replace(/\${level}/,s.toString()).replace(/\${message}/,a),u=m.get(f);if(void 0!==u){var c=void 0!==l.duration?l.duration:1e3;if(Date.now()-u<c)return}m.set(f,Date.now())}var p="";if(void 0!==e&&void 0!==e.stderr&&!0!==e.stderr.isTTY)p=JSON.stringify(t({time:(new Date).toISOString()},r));else{var g=s<0?0:s>3?3:s,y=i[g].toUpperCase().padEnd(5," ");if("undefined"!=typeof window)p=y+" "+o+" "+a;else{p=["🚨","⚠","🛈","🐛"][g]+" "+["","","",""][g]+y+" "+o+" "+a}var w=n.showStack;void 0!==w&&w&&void 0!==v&&(p+="\n "+v)}console.error(p)}}function g(e){return{error:function(r){v(r,e,i.error)},warn:function(r){v(r,e,i.warn)},info:function(r){v(r,e,i.info)},debug:function(r){v(r,e,i.debug)}}}exports.defaultHandler=p,0===d().length&&l(p),exports.getLogger=g;
},{"process":"g5IB"}]},{},["QCba"], "logga")
//# sourceMappingURL=/index.js.map

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

/**
* The severity level of a log event.
*/
export declare enum LogLevel {

@@ -7,6 +10,13 @@ error = 0,

}
export interface LogInfo {
/**
* Information supplied to the logger
* about a log event.
*/
export interface LogEvent {
message?: string;
stack?: string;
}
/**
* Data associated with a log event
*/
export interface LogData {

@@ -19,4 +29,13 @@ tag: string;

/**
* A listener for the log event must have this function signature.
* A log event emitter
*/
export interface Logger {
error(message: string | LogEvent): void;
warn(message: string | LogEvent): void;
info(message: string | LogEvent): void;
debug(message: string | LogEvent): void;
}
/**
* A log event handler
*/
export interface LogHandler {

@@ -79,2 +98,3 @@ (data: LogData): void;

maxLevel?: LogLevel;
showStack?: boolean;
throttle?: {

@@ -93,7 +113,2 @@ signature?: string;

*/
export declare function getLogger(tag: string): {
error(message: string | LogInfo): void;
warn(message: string | LogInfo): void;
info(message: string | LogInfo): void;
debug(message: string | LogInfo): void;
};
export declare function getLogger(tag: string): Logger;

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

}
/**
* The severity level of a log event.
*/
var LogLevel;

@@ -182,12 +185,10 @@ (function (LogLevel) {

*/
function defaultHandler(data, options) {
function defaultHandler(data, options = {}) {
const { tag, level, message, stack } = data;
// Skip if greater than desired reporting level
const maxLevel = options !== undefined && options.maxLevel !== undefined
? options.maxLevel
: LogLevel.info;
const { maxLevel = LogLevel.info } = options;
if (level > maxLevel)
return;
// Skip if within throttling duration for the event signature
const throttle = options !== undefined ? options.throttle : undefined;
const { throttle } = options;
if (throttle !== undefined) {

@@ -239,3 +240,4 @@ const signature = throttle.signature !== undefined ? throttle.signature : '';

}
if (stack !== undefined)
const { showStack = false } = options;
if (showStack && stack !== undefined)
entry += '\n ' + stack;

@@ -242,0 +244,0 @@ }

{
"name": "@stencila/logga",
"version": "2.0.0",
"version": "2.1.0",
"description": "Unified logging across related Javascript modules",

@@ -36,7 +36,7 @@ "main": "dist/lib/index.js",

"devDependencies": {
"@stencila/dev-config": "1.2.2",
"@stencila/dev-config": "1.2.3",
"@types/jest": "24.0.23",
"jest": "24.9.0",
"parcel": "1.12.4",
"ts-jest": "24.1.0",
"ts-jest": "24.2.0",
"typescript": "3.7.2"

@@ -43,0 +43,0 @@ },

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