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

plylog

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plylog - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

.github/PULL_REQUEST_TEMPLATE

186

index.js

@@ -11,127 +11,85 @@ /**

'use strict';
const winston = require('winston');
let consoleTransport = new (winston.transports.Console)({
level: 'info',
prettyPrint: true,
});
Object.defineProperty(exports, "__esModule", { value: true });
const winston = require("winston");
class PolymerLogger {
/**
* Constructs a new instance of PolymerLogger. This creates a new internal
* `winston` logger, which is what we use to handle most of our logging logic.
*
* @constructor
* @param {Object} [options]
* @param {string} [options.level] The minimum severity to log, defaults to 'info'
* @return {void}
*/
constructor(options) {
options = options || {};
this._logger = new (winston.Logger)({transports: [consoleTransport]});
this._logger.cli();
/**
* Logs an ERROR message, if the log level allows it. These should be used
* to give the user information about a serious error that occurred. Usually
* used right before the process exits.
* Constructs a new instance of PolymerLogger. This creates a new internal
* `winston` logger, which is what we use to handle most of our logging logic.
*
* Should generally called with getLogger() instead of calling directly.
*/
this.error = this._log.bind(this, 'error');
constructor(options) {
options = options || {};
this._transport = exports.defaultConfig.transportFactory({
level: options.level || 'info',
label: options.name || null,
prettyPrint: true,
});
this._logger = new winston.Logger({ transports: [this._transport] });
this._logger.cli();
this.error = this._log.bind(this, 'error');
this.warn = this._log.bind(this, 'warn');
this.info = this._log.bind(this, 'info');
this.debug = this._log.bind(this, 'debug');
}
/**
* Logs a WARN message, if the log level allows it. These should be used
* to give the user information about some unexpected issue that was
* encountered. Usually the process is able to continue, but the user should
* still be concerned and hopefully investigate further.
* Read the instance's level from our internal logger.
*/
this.warn = this._log.bind(this, 'warn');
get level() {
return this._transport.level;
}
/**
* Logs an INFO message, if the log level allows it. These should be used
* to give the user generatl information about the process, including progress
* updates and status messages.
* Sets a new logger level on the internal winston logger. The level dictates
* the minimum level severity that you will log to the console.
*/
this.info = this._log.bind(this, 'info');
set level(newLevel) {
this._transport.level = newLevel;
}
/**
* Logs a DEBUG message, if the log level allows it. These should be used
* to give the user useful information for debugging purposes. These will
* generally only be displayed when the user is are troubleshooting an
* issue.
* Logs a message of any level. Used internally by the public logging methods.
*/
this.debug = this._log.bind(this, 'debug');
}
/**
* Read the instance's level from our internal logger.
*
* @return {string}
*/
get level() {
return consoleTransport.level;
}
/**
* Sets a new logger level on the internal winston logger. The level dictates
* the minimum level severity that you will log to the console.
*
* @param {string} [newLevel] The new maximum severity that will be logged
* @return {void}
*/
set level(newLevel) {
consoleTransport.level = newLevel;
}
/**
* Logs a message of any level. Used internally by the public logging methods.
*
* @param {string} level The severity level of the log
* @param {string} msg The message to log
* @param {Object} [metadata] Optional metadata to log
* @return {void}
*/
_log() {
this._logger.log.apply(this._logger, arguments);
}
_log(_level, _msg, _metadata) {
this._logger.log.apply(this._logger, arguments);
}
}
module.exports = {
/**
* Set all future loggers created, across the application, to be verbose.
*
* @return {void}
*/
setVerbose: function() {
consoleTransport.level = 'debug';
},
/**
* Set all future loggers created, across the application, to be quiet.
*
* @return {void}
*/
setQuiet: function() {
consoleTransport.level = 'error';
},
/**
* Create a new logger with the given name label. It will inherit the global
* level if one has been set within the application.
*
* @param {string} name The name of the logger, useful for grouping messages
* @return {PolymerLogger}
*/
getLogger: function() {
exports.PolymerLogger = PolymerLogger;
exports.defaultConfig = {
level: 'info',
/**
* Replace this to replace the default transport factor for all future
* loggers.
*/
transportFactory(options) {
return new winston.transports.Console(options);
}
};
/**
* Set all future loggers created, across the application, to be verbose.
*/
function setVerbose() {
exports.defaultConfig.level = 'debug';
}
exports.setVerbose = setVerbose;
;
/**
* Set all future loggers created, across the application, to be quiet.
*/
function setQuiet() {
exports.defaultConfig.level = 'error';
}
exports.setQuiet = setQuiet;
/**
* Create a new logger with the given name label. It will inherit the global
* level if one has been set within the application.
*
* @param {string} name The name of the logger, useful for grouping messages
* @return {PolymerLogger}
*/
function getLogger(name) {
return new PolymerLogger({
level: this.level,
level: exports.defaultConfig.level,
name: name,
});
},
};
}
exports.getLogger = getLogger;
//# sourceMappingURL=index.js.map
{
"name": "plylog",
"version": "0.4.0",
"version": "0.5.0",
"description": "A logger for the Polymer CLI toolchain",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"test": "mocha test/ --ui tdd"
"test": "npm run build && mocha test/ --ui tdd",
"build": "tsc",
"prepublish": "npm run build"
},

@@ -17,9 +20,15 @@ "keywords": [

"dependencies": {
"@types/node": "^4.2.3",
"@types/winston": "^2.2.0",
"winston": "^2.2.0"
},
"devDependencies": {
"@types/chai": "^3.4.35",
"@types/mocha": "^2.2.39",
"@types/sinon": "^1.16.35",
"chai": "^3.5.0",
"mocha": "^2.4.5",
"sinon": "^1.17.4"
"mocha": "^3.2.0",
"sinon": "^1.17.4",
"typescript": "^2.2.1"
}
}

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