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

logplease

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logplease - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

package.json
{
"name": "logplease",
"version": "1.2.1",
"version": "1.2.2",
"description": "Simple Javascript logger for Node.js and Browsers",

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

@@ -15,2 +15,6 @@ 'use strict';

// Default log level
let GlobalLogLevel = LogLevels.DEBUG;
// ANSI colors
let Colors = {

@@ -29,2 +33,3 @@ 'Black': 0,

// CSS colors
if(!isNodejs) {

@@ -45,2 +50,4 @@ Colors = {

const loglevelColors = [Colors.Cyan, Colors.Green, Colors.Yellow, Colors.Red, Colors.Default];
const defaultOptions = {

@@ -55,5 +62,2 @@ useColors: true,

const loglevelColors = [Colors.Cyan, Colors.Green, Colors.Yellow, Colors.Red, Colors.Default];
let GlobalLogLevel = LogLevels.DEBUG;
class Logger {

@@ -123,21 +127,22 @@ constructor(category, options) {

if(this.options.useColors) {
if(isNodejs) {
const levelColor = Object.keys(LogLevels).map((f) => LogLevels[f]).indexOf(level);
const categoryColor = this.options.color;
if(isNodejs) {
if(this.options.showTimestamp)
timestampFormat = '\u001b[3' + Colors.Grey + 'm';
// timestampFormat = '\u001b[3' + loglevelColors[levelColor] + 'm';
levelFormat = '\u001b[3' + loglevelColors[levelColor] + ';22m';
categoryFormat = '\u001b[3' + categoryColor + ';1m';
textFormat = '\u001b[0m: ';
if(this.options.showLevel)
levelFormat = '\u001b[3' + loglevelColors[levelColor] + ';22m';
categoryFormat = '\u001b[3' + categoryColor + ';1m';
textFormat = '\u001b[0m: ';
} else {
const levelColor = Object.keys(LogLevels).map((f) => LogLevels[f]).indexOf(level);
const categoryColor = this.options.color;
if(this.options.showTimestamp)
timestampFormat = 'color:' + Colors.Grey;
levelFormat = 'color:' + loglevelColors[levelColor];
categoryFormat = 'color:' + categoryColor + '; font-weight: bold';
if(this.options.showLevel)
levelFormat = 'color:' + loglevelColors[levelColor];
categoryFormat = 'color:' + categoryColor + '; font-weight: bold';
}

@@ -163,21 +168,23 @@ }

timestampFormat = '%c';
levelFormat = '%c';
if(this.options.showLevel)
levelFormat = '%c';
categoryFormat = '%c';
textFormat = ': %c';
textFormat = ': %c';
}
let final = '';
let result = '';
if(this.options.showTimestamp)
final += '' + new Date().toISOString() + ' ';
result += '' + new Date().toISOString() + ' ';
final = timestampFormat + final;
result = timestampFormat + result;
if(this.options.showLevel)
final += levelFormat + '[' + level +']' + (level === LogLevels.INFO || level === LogLevels.WARN ? ' ' : '') + ' ';
result += levelFormat + '[' + level +']' + (level === LogLevels.INFO || level === LogLevels.WARN ? ' ' : '') + ' ';
final += categoryFormat + this.category;
final += textFormat + text;
final = final + '';
return final;
result += categoryFormat + this.category;
result += textFormat + text;
return result;
}

@@ -194,12 +201,9 @@

/* Public API */
// exports.Colors = Colors;
// exports.LogLevel = LogLevels;
// exports.setLogLevel = (level) => GlobalLogLevel = level;
// exports.create = (category, options) => new Logger(category, options);
module.exports = {
Colors: Colors,
LogLevel: LogLevels,
setLogLevel: (level) => GlobalLogLevel = level,
setLogLevel: (level) => {
GlobalLogLevel = level
},
create: (category, options) => new Logger(category, options),
};
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