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

@stencila/logga

Package Overview
Dependencies
Maintainers
2
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 1.0.0 to 1.1.0

18

dist/index.d.ts
export declare enum LogLevel {
emerg = 0,
alert = 1,
crit = 2,
error = 3,
warning = 4,
notice = 5,
info = 6,
debug = 7
error = 0,
warn = 1,
info = 2,
debug = 3
}

@@ -43,10 +39,6 @@ export interface LogInfo {

export declare function getLogger(appName: string): {
emerg(message: string | LogInfo): void;
alert(message: string | LogInfo): void;
crit(message: string | LogInfo): void;
error(message: string | LogInfo): void;
warning(message: string | LogInfo): void;
notice(message: string | LogInfo): void;
warn(message: string | LogInfo): void;
info(message: string | LogInfo): void;
debug(message: string | LogInfo): void;
};

@@ -6,10 +6,6 @@ "use strict";

(function (LogLevel) {
LogLevel[LogLevel["emerg"] = 0] = "emerg";
LogLevel[LogLevel["alert"] = 1] = "alert";
LogLevel[LogLevel["crit"] = 2] = "crit";
LogLevel[LogLevel["error"] = 3] = "error";
LogLevel[LogLevel["warning"] = 4] = "warning";
LogLevel[LogLevel["notice"] = 5] = "notice";
LogLevel[LogLevel["info"] = 6] = "info";
LogLevel[LogLevel["debug"] = 7] = "debug";
LogLevel[LogLevel["error"] = 0] = "error";
LogLevel[LogLevel["warn"] = 1] = "warn";
LogLevel[LogLevel["info"] = 2] = "info";
LogLevel[LogLevel["debug"] = 3] = "debug";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));

@@ -55,3 +51,3 @@ /**

function (data) {
console.error(data.appName + ': ' + data.message);
console.error(data.appName + " - [" + LogLevel[data.level].toUpperCase() + "] - " + data.message);
};

@@ -72,20 +68,8 @@ // @ts-ignore

return {
emerg: function (message) {
emitLogData(message, appName, LogLevel.emerg);
},
alert: function (message) {
emitLogData(message, appName, LogLevel.alert);
},
crit: function (message) {
emitLogData(message, appName, LogLevel.crit);
},
error: function (message) {
emitLogData(message, appName, LogLevel.error);
},
warning: function (message) {
emitLogData(message, appName, LogLevel.warning);
warn: function (message) {
emitLogData(message, appName, LogLevel.warn);
},
notice: function (message) {
emitLogData(message, appName, LogLevel.notice);
},
info: function (message) {

@@ -92,0 +76,0 @@ emitLogData(message, appName, LogLevel.info);

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

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

const LOG_EVENT_NAME = Symbol('stencila:logga')
export enum LogLevel {
emerg = 0,
alert,
crit,
error,
warning,
notice,
error = 0,
warn,
info,

@@ -43,3 +39,3 @@ debug

function emitLogData(info: LogInfo | string, appName: string, level: LogLevel) {
let message
let message: string
if (typeof info === 'object') {

@@ -51,3 +47,3 @@ message = info.message

let stackTrace
let stackTrace: string
if (typeof info === 'object' && info.stackTrace) {

@@ -76,3 +72,7 @@ stackTrace = info.stackTrace

function(data: LogData) {
console.error(data.appName + ': ' + data.message)
console.error(
`${data.appName} - [${LogLevel[data.level].toUpperCase()}] - ${
data.message
}`
)
}

@@ -93,20 +93,8 @@ // @ts-ignore

return {
emerg(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.emerg)
},
alert(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.alert)
},
crit(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.crit)
},
error(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.error)
},
warning(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.warning)
warn(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.warn)
},
notice(message: string | LogInfo) {
emitLogData(message, appName, LogLevel.notice)
},
info(message: string | LogInfo) {

@@ -113,0 +101,0 @@ emitLogData(message, appName, LogLevel.info)

@@ -17,3 +17,5 @@ import { getLogger, addHandler, LogData, LogLevel } from '../src'

log.debug('a debug message')
expect(consoleError).toHaveBeenCalledWith(__filename + ': a debug message')
expect(consoleError).toHaveBeenCalledWith(
__filename + ' - [DEBUG] - a debug message'
)
expect(events.length).toBe(1)

@@ -29,3 +31,5 @@ expect(events[0].appName).toBe(APPNAME)

})
expect(consoleError).toHaveBeenCalledWith(__filename + ': a info message')
expect(consoleError).toHaveBeenCalledWith(
__filename + ' - [INFO] - a info message'
)
expect(events.length).toBe(2)

@@ -37,19 +41,7 @@ expect(events[1].appName).toBe(APPNAME)

log.notice('a notice message')
expect(events[2].level).toBe(LogLevel.notice)
log.warn('a warning message')
expect(events[2].level).toBe(LogLevel.warn)
log.warning('a warning message')
expect(events[3].level).toBe(LogLevel.warning)
log.error('a error message')
expect(events[4].level).toBe(LogLevel.error)
log.crit('a crit message')
expect(events[5].level).toBe(LogLevel.crit)
log.alert('a alert message')
expect(events[6].level).toBe(LogLevel.alert)
log.emerg('a emerg message')
expect(events[7].level).toBe(LogLevel.emerg)
log.error('an error message')
expect(events[3].level).toBe(LogLevel.error)
})
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