A Log Level property is added just like any other custom operator property, and used in the init() method to have an effect.
Steps:
1. Add the property:
private LogLevel logLevel = LogLevel.INFO;
2. Add the getter and setter:
public LogLevel getLogLevel() { return this.logLevel; } public void setLogLevel(LogLevel level) { this.logLevel = level; }
3. Use the value in init():
public void init() throws StreamBaseException { super.init(); Operator.setLogLevel(logger, getLogLevel()); }
4. Wherever needed, call the logger:
if (logger.isDebugEnabled()) { logger.debug("operator processing a tuple at input port" + inputPort + ", value: " + tuple.toString()); }
5. In the BeanInfo.java file, tell Studio that the Log Level property exists:
public SBPropertyDescriptor[] getPropertyDescriptorsChecked() throws IntrospectionException { return new SBPropertyDescriptor[] { new JavaEnumPropertyDescriptor<Operator.LogLevel>("logLevel", MyOperator.class, Operator.LogLevel.class).optional(). displayName("Log Level"). description("The log level used by the operator. Independent of the top-level StreamBase log level value.") }; }