You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2017/04/13 02:11:56 UTC

[1/4] storm git commit: STORM-2435: Logging now supports logging levels (trace, debug, info, warn and error). Logging methods now accept multiple arguments and argument types are not restricted. Some style fixes to make it more co

Repository: storm
Updated Branches:
  refs/heads/master 4f99514e4 -> 4c27ef9d3


STORM-2435: Logging now supports logging levels (trace, debug, info, warn and error).
            Logging methods now accept multiple arguments and argument types are not restricted.
            Some style fixes to make it more consistent.


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/457f422f
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/457f422f
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/457f422f

Branch: refs/heads/master
Commit: 457f422fe48744771722e4bd3ba781d6d915f2e2
Parents: 21f365e
Author: Aki M�kinen <ak...@outlook.com>
Authored: Mon Mar 27 22:47:34 2017 +0300
Committer: Aki M�kinen <ak...@outlook.com>
Committed: Mon Mar 27 22:55:09 2017 +0300

----------------------------------------------------------------------
 .../src/main/resources/resources/storm.js       | 122 ++++++++++++-------
 1 file changed, 76 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/457f422f/storm-multilang/javascript/src/main/resources/resources/storm.js
----------------------------------------------------------------------
diff --git a/storm-multilang/javascript/src/main/resources/resources/storm.js b/storm-multilang/javascript/src/main/resources/resources/storm.js
index 206119c..1481362 100755
--- a/storm-multilang/javascript/src/main/resources/resources/storm.js
+++ b/storm-multilang/javascript/src/main/resources/resources/storm.js
@@ -25,38 +25,68 @@
 var fs = require('fs');
 
 function Storm() {
-    this.messagePart = "";
+    this.messagePart = '';
     this.taskIdsCallbacks = [];
     this.isFirstMessage = true;
     this.separator = '\nend\n';
+    this.logLevels = {
+        trace: 0, debug: 1, info: 2, warn: 3, error: 4
+    }
 }
 
 Storm.prototype.sendMsgToParent = function(msg) {
     var str = JSON.stringify(msg);
     process.stdout.write(str + this.separator);
-}
+};
 
 Storm.prototype.sync = function() {
-    this.sendMsgToParent({"command":"sync"});
-}
+    this.sendMsgToParent({'command':'sync'});
+};
 
 Storm.prototype.sendPid = function(heartbeatdir) {
     var pid = process.pid;
-    fs.closeSync(fs.openSync(heartbeatdir + "/" + pid, "w"));
-    this.sendMsgToParent({"pid": pid})
-}
+    fs.closeSync(fs.openSync(heartbeatdir + '/' + pid, 'w'));
+    this.sendMsgToParent({'pid': pid})
+};
+Storm.prototype.sendToLogging = function(args, logLevel) {
+    var argArray = Object.keys(args).map(function(key) {
+        return (typeof args[key] === 'string') ? args[key] : JSON.stringify(args[key]);
+    });
+    var msg = argArray.join(' ');
+    this.sendMsgToParent({'command': 'log', 'msg': msg, 'level': logLevel});
+};
 
-Storm.prototype.log = function(msg) {
-    this.sendMsgToParent({"command": "log", "msg": msg});
-}
+Storm.prototype.log = function() {
+    this.sendToLogging(arguments, this.logLevels.info);
+};
+
+Storm.prototype.trace = function() {
+    this.sendToLogging(arguments, this.logLevels.trace);
+};
+
+Storm.prototype.debug = function() {
+    this.sendToLogging(arguments, this.logLevels.debug);
+};
+
+Storm.prototype.info = function() {
+    this.sendToLogging(arguments, this.logLevels.info);
+};
+
+Storm.prototype.warn = function() {
+    this.sendToLogging(arguments, this.logLevels.warn);
+};
+
+Storm.prototype.error = function() {
+    this.sendToLogging(arguments, this.logLevels.error);
+};
 
 Storm.prototype.initSetupInfo = function(setupInfo) {
     var self = this;
     var callback = function() {
         self.sendPid(setupInfo['pidDir']);
-    }
+    };
     this.initialize(setupInfo['conf'], setupInfo['context'], callback);
-}
+};
 
 Storm.prototype.startReadingInput = function() {
     var self = this;
@@ -68,7 +98,7 @@ Storm.prototype.startReadingInput = function() {
         })
 
     });
-}
+};
 
 /**
  * receives a new string chunk and returns a list of new messages with the separator removed
@@ -98,11 +128,11 @@ Storm.prototype.handleNewChunk = function(chunk) {
         }
     }
     return messages;
-}
+};
 
 Storm.prototype.isTaskIds = function(msg) {
     return (msg instanceof Array);
-}
+};
 
 Storm.prototype.handleNewMessage = function(msg) {
     var parsedMsg = JSON.parse(msg);
@@ -115,7 +145,7 @@ Storm.prototype.handleNewMessage = function(msg) {
     } else {
         this.handleNewCommand(parsedMsg);
     }
-}
+};
 
 Storm.prototype.handleNewTaskId = function(taskIds) {
     //When new list of task ids arrives, the callback that was passed with the corresponding emit should be called.
@@ -128,7 +158,7 @@ Storm.prototype.handleNewTaskId = function(taskIds) {
     } else {
         throw new Error('Something went wrong, we off the split of task id callbacks');
     }
-}
+};
 
 
 
@@ -166,8 +196,8 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
     }
 
     this.taskIdsCallbacks.push(onTaskIds);
-    this.__emit(messageDetails);;
-}
+    this.__emit(messageDetails);
+};
 
 
 /**
@@ -193,10 +223,10 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
  */
 Storm.prototype.emitDirect = function(commandDetails) {
     if (!commandDetails.task) {
-        throw new Error("Emit direct must receive task id!")
+        throw new Error('Emit direct must receive task id!')
     }
     this.__emit(commandDetails);
-}
+};
 
 /**
  * Initialize storm component according to the configuration received.
@@ -206,13 +236,13 @@ Storm.prototype.emitDirect = function(commandDetails) {
  */
 Storm.prototype.initialize = function(conf, context, done) {
     done();
-}
+};
 
 Storm.prototype.run = function() {
     process.stdout.setEncoding('utf8');
     process.stdin.setEncoding('utf8');
     this.startReadingInput();
-}
+};
 
 function Tuple(id, component, stream, task, values) {
     this.id = id;
@@ -223,12 +253,12 @@ function Tuple(id, component, stream, task, values) {
 }
 
 Tuple.prototype.isTickTuple = function(){
-  return this.task === -1 && this.stream === "__tick";
-}
+  return this.task === -1 && this.stream === '__tick';
+};
 
 Tuple.prototype.isHeartbeatTuple = function(){
-  return this.task === -1 && this.stream === "__heartbeat";
-}
+  return this.task === -1 && this.stream === '__heartbeat';
+};
 
 /**
  * Base class for storm bolt.
@@ -238,7 +268,7 @@ Tuple.prototype.isHeartbeatTuple = function(){
 function BasicBolt() {
     Storm.call(this);
     this.anchorTuple = null;
-};
+}
 
 BasicBolt.prototype = Object.create(Storm.prototype);
 BasicBolt.prototype.constructor = BasicBolt;
@@ -264,7 +294,7 @@ BasicBolt.prototype.__emit = function(commandDetails) {
     }
 
     var message = {
-        command: "emit",
+        command: 'emit',
         tuple: commandDetails.tuple,
         stream: commandDetails.stream,
         task: commandDetails.task,
@@ -272,11 +302,11 @@ BasicBolt.prototype.__emit = function(commandDetails) {
     };
 
     this.sendMsgToParent(message);
-}
+};
 
 BasicBolt.prototype.handleNewCommand = function(command) {
     var self = this;
-    var tup = new Tuple(command["id"], command["comp"], command["stream"], command["task"], command["tuple"]);
+    var tup = new Tuple(command['id'], command['comp'], command['stream'], command['task'], command['tuple']);
 
     if (tup.isHeartbeatTuple()) {
         self.sync();
@@ -289,9 +319,9 @@ BasicBolt.prototype.handleNewCommand = function(command) {
             return;
         }
         self.ack(tup);
-    }
+    };
     this.process(tup, callback);
-}
+};
 
 /**
  * Implement this method when creating a bolt. This is the main method that provides the logic of the bolt (what
@@ -302,12 +332,12 @@ BasicBolt.prototype.handleNewCommand = function(command) {
 BasicBolt.prototype.process = function(tuple, done) {};
 
 BasicBolt.prototype.ack = function(tup) {
-    this.sendMsgToParent({"command": "ack", "id": tup.id});
-}
+    this.sendMsgToParent({'command': 'ack', 'id': tup.id});
+};
 
 BasicBolt.prototype.fail = function(tup, err) {
-    this.sendMsgToParent({"command": "fail", "id": tup.id});
-}
+    this.sendMsgToParent({'command': 'fail', 'id': tup.id});
+};
 
 /**
  * Base class for storm spout.
@@ -318,7 +348,7 @@ BasicBolt.prototype.fail = function(tup, err) {
  */
 function Spout() {
     Storm.call(this);
-};
+}
 
 Spout.prototype = Object.create(Storm.prototype);
 
@@ -351,18 +381,18 @@ Spout.prototype.handleNewCommand = function(command) {
         self.sync();
     }
 
-    if (command["command"] === "next") {
+    if (command['command'] === 'next') {
         this.nextTuple(callback);
     }
 
-    if (command["command"] === "ack") {
-        this.ack(command["id"], callback);
+    if (command['command'] === 'ack') {
+        this.ack(command['id'], callback);
     }
 
-    if (command["command"] === "fail") {
-        this.fail(command["id"], callback);
+    if (command['command'] === 'fail') {
+        this.fail(command['id'], callback);
     }
-}
+};
 
 /**
  * @param commandDetails json with the required fields:
@@ -374,7 +404,7 @@ Spout.prototype.handleNewCommand = function(command) {
  */
 Spout.prototype.__emit = function(commandDetails) {
     var message = {
-        command: "emit",
+        command: 'emit',
         tuple: commandDetails.tuple,
         id: commandDetails.id,
         stream: commandDetails.stream,
@@ -382,7 +412,7 @@ Spout.prototype.__emit = function(commandDetails) {
     };
 
     this.sendMsgToParent(message);
-}
+};
 
 module.exports.BasicBolt = BasicBolt;
 module.exports.Spout = Spout;


[2/4] storm git commit: Changed the names of the logging methods to be inline with the Python module.

Posted by bo...@apache.org.
Changed the names of the logging methods to be inline with the Python module.


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/5913d160
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/5913d160
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/5913d160

Branch: refs/heads/master
Commit: 5913d160fa38efc3e8888e761e075582ba8c8a5f
Parents: 457f422
Author: Aki M�kinen <ak...@outlook.com>
Authored: Tue Mar 28 18:19:06 2017 +0300
Committer: Aki M�kinen <ak...@outlook.com>
Committed: Tue Mar 28 18:19:06 2017 +0300

----------------------------------------------------------------------
 .../src/main/resources/resources/storm.js          | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/5913d160/storm-multilang/javascript/src/main/resources/resources/storm.js
----------------------------------------------------------------------
diff --git a/storm-multilang/javascript/src/main/resources/resources/storm.js b/storm-multilang/javascript/src/main/resources/resources/storm.js
index 1481362..25e0a6d 100755
--- a/storm-multilang/javascript/src/main/resources/resources/storm.js
+++ b/storm-multilang/javascript/src/main/resources/resources/storm.js
@@ -56,30 +56,29 @@ Storm.prototype.sendToLogging = function(args, logLevel) {
     this.sendMsgToParent({'command': 'log', 'msg': msg, 'level': logLevel});
 };
 
-Storm.prototype.log = function() {
-    this.sendToLogging(arguments, this.logLevels.info);
-};
-
-Storm.prototype.trace = function() {
+Storm.prototype.logTrace = function() {
     this.sendToLogging(arguments, this.logLevels.trace);
 };
 
-Storm.prototype.debug = function() {
+Storm.prototype.logDebug = function() {
     this.sendToLogging(arguments, this.logLevels.debug);
 };
 
-Storm.prototype.info = function() {
+Storm.prototype.logInfo = function() {
     this.sendToLogging(arguments, this.logLevels.info);
 };
 
-Storm.prototype.warn = function() {
+Storm.prototype.logWarn = function() {
     this.sendToLogging(arguments, this.logLevels.warn);
 };
 
-Storm.prototype.error = function() {
+Storm.prototype.logError = function() {
     this.sendToLogging(arguments, this.logLevels.error);
 };
 
+// For backwards compatibility
+Storm.prototype.log = Storm.prototype.logInfo;
+
 Storm.prototype.initSetupInfo = function(setupInfo) {
     var self = this;
     var callback = function() {


[4/4] storm git commit: Added STORM-2435 to Changelog

Posted by bo...@apache.org.
Added STORM-2435 to Changelog


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/4c27ef9d
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/4c27ef9d
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/4c27ef9d

Branch: refs/heads/master
Commit: 4c27ef9d36b0fa1239cfef2ba5e8e1f2f99b43e7
Parents: 8b10417
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Wed Apr 12 20:59:26 2017 -0500
Committer: Robert Evans <ev...@yahoo-inc.com>
Committed: Wed Apr 12 20:59:26 2017 -0500

----------------------------------------------------------------------
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/4c27ef9d/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0378e4a..d626c6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 \ufeff## 2.0.0
+ * STORM-2435: Logging levels and consistency with console.log etc
  * STORM-2465: modify storm-redis's READEME.md and update storm-redis.md
  * STORM-2464: update storm-mongodb.md
  * STORM-2463: fix DRPCTest.testDequeueAfterTimeout test failure 


[3/4] storm git commit: Merge branch 'STORM-2435' of https://github.com/XC-/storm into STORM-2435

Posted by bo...@apache.org.
Merge branch 'STORM-2435' of https://github.com/XC-/storm into STORM-2435

STORM-2435: Logging levels and consistency with console.log etc


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/8b104174
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/8b104174
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/8b104174

Branch: refs/heads/master
Commit: 8b1041744e1d236eb4f1b37b0ca2c6b7a2685f1b
Parents: 4f99514 5913d16
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Wed Apr 12 20:59:06 2017 -0500
Committer: Robert Evans <ev...@yahoo-inc.com>
Committed: Wed Apr 12 20:59:06 2017 -0500

----------------------------------------------------------------------
 .../src/main/resources/resources/storm.js       | 121 ++++++++++++-------
 1 file changed, 75 insertions(+), 46 deletions(-)
----------------------------------------------------------------------