Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Add more log levels, colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Efreak committed Aug 7, 2015
1 parent 71cb14a commit ec4b17f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/chatBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ if (fs.existsSync(serversFile)) {
winston.warn("No servers file found, using defaults");
}

var wcfg = { //define some extra logLevels for winston, also colors
levels: {
spam: 0, protocol: 1, silly: 2, verbose: 3, info: 4,
data: 5, warn: 6, debug: 7, error: 8, failure: 9
},
colors: {
spam:'bold', protocol:'grey', silly:'white', verbose:'cyan', info:'green',
data:'gray', warn:'yellow', debug:'blue', error:'red', failure:'rainbow'
}
}

// Bot should be usually created without options, it is a parameter mainly for testing
var ChatBot = function(username, password, options) {
var that = this;

this.version = ver;
this.winston = new winston.Logger;
this.options = options || {};

this.winston = new (winston.Logger)({levels:wcfg.levels, colors: options.winstonColors||wcfg.colors});

this.steamClient = options.client || new steam.SteamClient();
this.steamUser = options.user || new steam.SteamUser(this.steamClient);
Expand Down Expand Up @@ -618,7 +627,7 @@ ChatBot.prototype._onConnected = function() {

ChatBot.prototype._onMessage = function(header, body, callback) {
var that = this;
this.winston.silly('ChatBot ' + this.name + ' new ProtoBuf message: ' + header.msg + (header.proto ? ', ' + JSON.stringify(header.proto) : ''));
this.winston.protocol('ChatBot ' + this.name + ' new ProtoBuf message: ' + header.msg + (header.proto ? ', ' + JSON.stringify(header.proto) : ''));
}

ChatBot.prototype._onError = function() {
Expand Down

1 comment on commit ec4b17f

@kjsmita6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh you should have left silly as the magenta color, since silly and protocol look the exact same.

Please sign in to comment.