这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ var log = function () {
log.info.apply(log, Array.prototype.slice.call(arguments));
};

var ansi;

if (typeof require === 'function' && typeof window === 'undefined') {
ansi = require('ansi-styles');
}

log.setColor = function (enable) {
if (enable && ansi) {
if (enable && (typeof require === 'function') && (typeof window === 'undefined') && process && process.platform !== 'win32') {
var ansi = require('ansi-styles');
this.map = {
debug: ansi.bgBlue.open +
'<debug>' +
Expand Down Expand Up @@ -62,7 +57,7 @@ log._debug = function () {
var args = Array.prototype.slice.call(arguments);
if (this.severity) args.unshift(log.map.debug);
if (this.timestamp) args.unshift(this.ts());
this.stdout.apply(this, args);
this.stdout.apply(console, args);
};
log._info = function () {
var args = Array.prototype.slice.call(arguments);
Expand Down Expand Up @@ -123,7 +118,7 @@ log.setLevel = function (lvl) {
};

// set defaults
log.setColor(process.platform !== 'win32' && typeof require !== 'undefined' && typeof window === 'undefined');
log.setColor(true);
log.setTimestamp(true);
log.setSeverity(true);
log.setLevel('info');
Expand All @@ -137,5 +132,3 @@ if (typeof define === 'function' && define.amd) {
} else {
window.log = log;
}