Socket
Socket
Sign inDemoInstall

@dxos/log

Package Overview
Dependencies
Maintainers
13
Versions
2240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxos/log - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

3

dist/src/config.d.ts

@@ -38,2 +38,3 @@ import { LogProcessor } from './context';

filter?: string | string[] | LogLevel;
depth?: number;
processor?: string | LogProcessorType;

@@ -43,2 +44,3 @@ formatter?: {

};
prefix?: string;
};

@@ -52,3 +54,4 @@ /**

processor: LogProcessor;
prefix?: string;
}
//# sourceMappingURL=config.d.ts.map

6

dist/src/options.js

@@ -45,3 +45,4 @@ "use strict";

options = (0, lodash_defaultsdeep_1.default)({}, (0, platform_1.loadOptions)(options.file), options);
console.log(JSON.stringify(options, undefined, 2));
// TODO(burdon): Verbose option.
// console.log(JSON.stringify(options, undefined, 2));
}

@@ -52,3 +53,4 @@ const defaultProcessor = IS_BROWSER ? processors_1.BROWSER_PROCESSOR : processors_1.CONSOLE_PROCESSOR;

filters: (0, exports.parseFilter)((_d = options.filter) !== null && _d !== void 0 ? _d : config_1.LogLevel.INFO),
processor: options.processor ? exports.processors[options.processor] : defaultProcessor
processor: options.processor ? exports.processors[options.processor] : defaultProcessor,
prefix: options.prefix
};

@@ -55,0 +57,0 @@ };

@@ -20,29 +20,41 @@ "use strict";

const BROWSER_PROCESSOR = (config, entry) => {
var _a, _b;
var _a, _b, _c, _d;
if (!(0, context_1.shouldLog)(config, entry.level, (_b = (_a = entry.meta) === null || _a === void 0 ? void 0 : _a.file) !== null && _b !== void 0 ? _b : '')) {
return;
}
const args = [];
// Example local editor prefix: 'vscode://file/Users/burdon/Code/dxos/dxos/'.
const LOG_BROWSER_PREFIX = (_c = config.prefix) !== null && _c !== void 0 ? _c : 'https://vscode.dev/github.com/dxos/dxos/blob/main/';
// TODO(burdon): CSS breaks formatting (e.g., [Object] rather than expandable property).
// TODO(burdon): Consider custom formatters.
// https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
// NOTE: Cannot change color of link (from bright white).
// const LOG_BROWSER_CSS = ['color:gray; font-size:10px; padding-bottom: 4px', 'color:#B97852; font-size:14px;'];
const LOG_BROWSER_CSS = [];
let link = '';
if (entry.meta) {
args.push(`${getRelativeFilename(entry.meta.file)}:${entry.meta.line}`);
const filename = getRelativeFilename(entry.meta.file);
const filepath = `${LOG_BROWSER_PREFIX.replace(/\/$/, '')}/${filename}`;
// TODO(burdon): Line numbers not working for app link, even with colons.
// https://stackoverflow.com/a/54459820/2804332
link = `${filepath}#L${entry.meta.line}`;
}
args.push(`${config_1.shortLevelName[entry.level]} ${entry.message}`);
const args = [];
args.push(entry.message);
if (entry.context && Object.keys(entry.context).length > 0) {
args.push(entry.context);
}
switch (entry.level) {
case config_1.LogLevel.ERROR: {
console.error(...args);
break;
}
case config_1.LogLevel.WARN: {
console.warn(...args);
break;
}
default: {
console.log(...args);
}
const levels = {
[config_1.LogLevel.ERROR]: console.error,
[config_1.LogLevel.WARN]: console.warn,
[config_1.LogLevel.DEBUG]: console.log
};
const level = (_d = levels[entry.level]) !== null && _d !== void 0 ? _d : console.log;
if (LOG_BROWSER_CSS === null || LOG_BROWSER_CSS === void 0 ? void 0 : LOG_BROWSER_CSS.length) {
level.call(level, `%c${link}\n%c${args.join(' ')}`, ...LOG_BROWSER_CSS);
}
else {
level.call(level, link + '\n', ...args);
}
};
exports.BROWSER_PROCESSOR = BROWSER_PROCESSOR;
//# sourceMappingURL=browser-processor.js.map

@@ -79,3 +79,3 @@ "use strict";

// https://nodejs.org/api/util.html#utilinspectobject-options
parts.context = (0, node_util_1.inspect)((0, lodash_pickby_1.default)(context, (value) => value !== undefined), { depth: undefined, colors: true, maxArrayLength: 8, sorted: true });
parts.context = (0, node_util_1.inspect)((0, lodash_pickby_1.default)(context, (value) => value !== undefined), { depth: config.options.depth, colors: true, maxArrayLength: 8, sorted: false });
}

@@ -82,0 +82,0 @@ const line = formatter(config, parts).filter(Boolean).join(' ');

{
"name": "@dxos/log",
"version": "0.1.5",
"version": "0.1.6",
"description": "Logger",

@@ -5,0 +5,0 @@ "homepage": "https://dxos.org",

@@ -51,2 +51,3 @@ //

filter?: string | string[] | LogLevel;
depth?: number; // Context object depth.
processor?: string | LogProcessorType;

@@ -56,2 +57,3 @@ formatter?: {

};
prefix?: string;
};

@@ -66,2 +68,3 @@

processor: LogProcessor;
prefix?: string;
}

@@ -51,3 +51,4 @@ //

options = defaultsDeep({}, loadOptions(options.file), options);
console.log(JSON.stringify(options, undefined, 2));
// TODO(burdon): Verbose option.
// console.log(JSON.stringify(options, undefined, 2));
}

@@ -60,4 +61,5 @@

filters: parseFilter(options.filter ?? LogLevel.INFO),
processor: options.processor ? processors[options.processor] : defaultProcessor
processor: options.processor ? processors[options.processor] : defaultProcessor,
prefix: options.prefix
};
};

@@ -5,3 +5,3 @@ //

import { LogLevel, shortLevelName } from '../config';
import { LogLevel } from '../config';
import { LogProcessor, shouldLog } from '../context';

@@ -26,10 +26,23 @@

const args = [];
// Example local editor prefix: 'vscode://file/Users/burdon/Code/dxos/dxos/'.
const LOG_BROWSER_PREFIX = config.prefix ?? 'https://vscode.dev/github.com/dxos/dxos/blob/main/';
// TODO(burdon): CSS breaks formatting (e.g., [Object] rather than expandable property).
// TODO(burdon): Consider custom formatters.
// https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
// NOTE: Cannot change color of link (from bright white).
// const LOG_BROWSER_CSS = ['color:gray; font-size:10px; padding-bottom: 4px', 'color:#B97852; font-size:14px;'];
const LOG_BROWSER_CSS: string[] = [];
let link = '';
if (entry.meta) {
args.push(`${getRelativeFilename(entry.meta.file)}:${entry.meta.line}`);
const filename = getRelativeFilename(entry.meta.file);
const filepath = `${LOG_BROWSER_PREFIX.replace(/\/$/, '')}/${filename}`;
// TODO(burdon): Line numbers not working for app link, even with colons.
// https://stackoverflow.com/a/54459820/2804332
link = `${filepath}#L${entry.meta.line}`;
}
args.push(`${shortLevelName[entry.level]} ${entry.message}`);
const args = [];
args.push(entry.message);
if (entry.context && Object.keys(entry.context).length > 0) {

@@ -39,15 +52,14 @@ args.push(entry.context);

switch (entry.level) {
case LogLevel.ERROR: {
console.error(...args);
break;
}
case LogLevel.WARN: {
console.warn(...args);
break;
}
default: {
console.log(...args);
}
const levels: any = {
[LogLevel.ERROR]: console.error,
[LogLevel.WARN]: console.warn,
[LogLevel.DEBUG]: console.log
};
const level = levels[entry.level] ?? console.log;
if (LOG_BROWSER_CSS?.length) {
level.call(level, `%c${link}\n%c${args.join(' ')}`, ...LOG_BROWSER_CSS);
} else {
level.call(level, link + '\n', ...args);
}
};

@@ -98,3 +98,3 @@ //

pickBy(context, (value?: unknown) => value !== undefined),
{ depth: undefined, colors: true, maxArrayLength: 8, sorted: true }
{ depth: config.options.depth, colors: true, maxArrayLength: 8, sorted: false }
);

@@ -101,0 +101,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

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