mstrucken commented on issue #7954:
URL: https://github.com/apache/storm/issues/7954#issuecomment-2634390738

   The essential code from `multilang/resources/storm.py`:
   
   ```python
   def sendMsgToParent(msg):
       print(json_encode(msg))
       print("end")
       sys.stdout.flush()
   
   def log(msg, level=2):
       sendMsgToParent({"command": "log", "msg": msg, "level":level})
   
   def logTrace(msg):
       log(msg, 0)
   
   def logDebug(msg):
       log(msg, 1)
   
   def logInfo(msg):
       log(msg, 2)
   
   def logWarn(msg):
       log(msg, 3)
   
   def logError(msg):
       log(msg, 4)
   ```
   
   The json encoded messages:
   
   ```json
   {"command": "log", "msg": "Python bolt starting...", "level": 2}
   {"command": "log", "msg": "This is a sample warning", "level": 3}
   {"command": "log", "msg": "Error processing tuple with python...", "level": 
4}
   ```
   
   The message is deserialized using 
`org.apache.storm.multilang.JsonSerializer`:
   
   ```java
       public ShellMsg readShellMsg() throws IOException, NoOutputException {
           JSONObject msg = (JSONObject)this.readMessage();
           ShellMsg shellMsg = new ShellMsg();
           String command = (String)msg.get("command");
                
                // ...  
                
           if (command.equals("log")) {
               Object logLevelObj = msg.get("level");
               if (logLevelObj != null && logLevelObj instanceof Long) {
                   long logLevel = (Long)logLevelObj;
                   shellMsg.setLogLevel((int)logLevel);
               }
           }
   
           return shellMsg;
       }
   ```
   
   But `logLevelObj` is not an instance of `Long` but an instance of `Integer`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@storm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to