-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
o.a.s.t.ShellBolt log level is always INFO #7954
Comments
The essential code from 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: {"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} A single message is deserialized using 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 |
Thanks for the report. Do you want to create a PR for it? |
To be a little more relaxed about the deserialized numeric type, the check could be changed as follows: if (command.equals("log")) {
Object logLevelObj = msg.get("level");
if (logLevelObj != null && logLevelObj instanceof Number) {
int logLevel = ((Number) logLevelObj).intValue();
shellMsg.setLogLevel(logLevel);
}
} |
Will create a PR for this, @rzo1 |
Example bolt written in Python (
multilang/resources/log_level.py
):A minimal bolt that extends the
ShellBolt
used to execute the Python bolt above:Output:
Expected output:
The text was updated successfully, but these errors were encountered: