Logger
Writes lines to the client log. In the developer client they show in the Debugger's Log tab under your plugin's name.
InterfaceLoggingSLF4J docs
public interface LoggerMake one per class with LoggerFactory.getLogger(…) and keep it in a static final field. Put values in with {} instead of joining text: the line is only built when it is written.
Example
package com.example.tickcounter;
import net.runelite.api.events.GameTick;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@PluginDescriptor(name = "Tick Counter")
public final class TickCounterPlugin extends Plugin {
private static final Logger log = LoggerFactory.getLogger(TickCounterPlugin.class);
private int ticks;
@Override
protected void startUp() {
log.info("Started");
}
@Subscribe
public void onGameTick(GameTick tick) {
ticks++;
if (ticks % 100 == 0) {
log.debug("{} ticks so far", ticks);
}
}
}Members
Methods
- voiddebug(String)
Writes a DEBUG line: detail you need while testing.
- voiddebug(String, Object)
Writes a DEBUG line with one value.
- voiddebug(String, Object...)
Writes a DEBUG line with any number of values.
- voiddebug(String, Throwable)
Writes a DEBUG line and an error's stack trace.
- voiddebug(String, Object, Object)
Writes a DEBUG line with two values.
- voiderror(String)
Writes a ERROR line: something failed.
- voiderror(String, Object)
Writes a ERROR line with one value.
- voiderror(String, Object...)
Writes a ERROR line with any number of values.
- voiderror(String, Throwable)
Writes a ERROR line and an error's stack trace.
- voiderror(String, Object, Object)
Writes a ERROR line with two values.
- StringgetName()
The logger's name: the class you made it for.
- voidinfo(String)
Writes a INFO line: normal progress.
- voidinfo(String, Object)
Writes a INFO line with one value.
- voidinfo(String, Object...)
Writes a INFO line with any number of values.
- voidinfo(String, Throwable)
Writes a INFO line and an error's stack trace.
- voidinfo(String, Object, Object)
Writes a INFO line with two values.
- booleanisDebugEnabled()
Whether DEBUG lines are written.
- booleanisErrorEnabled()
Whether ERROR lines are written.
- booleanisInfoEnabled()
Whether INFO lines are written.
- booleanisTraceEnabled()
Whether TRACE lines are written.
- booleanisWarnEnabled()
Whether WARN lines are written.
- voidtrace(String)
Writes a TRACE line: the finest detail, hidden unless you turn it on.
- voidtrace(String, Object)
Writes a TRACE line with one value.
- voidtrace(String, Object...)
Writes a TRACE line with any number of values.
- voidtrace(String, Throwable)
Writes a TRACE line and an error's stack trace.
- voidtrace(String, Object, Object)
Writes a TRACE line with two values.
- voidwarn(String)
Writes a WARN line: something unexpected that the plugin handled.
- voidwarn(String, Object)
Writes a WARN line with one value.
- voidwarn(String, Object...)
Writes a WARN line with any number of values.
- voidwarn(String, Throwable)
Writes a WARN line and an error's stack trace.
- voidwarn(String, Object, Object)
Writes a WARN line with two values.
debug(String)
public void debug(String msg)Writes a DEBUG line: detail you need while testing.
Parameters
msg- The line.
debug(String, Object)
public void debug(String format, Object arg)Writes a DEBUG line with one value.
Parameters
format- The line, with
{}where the value goes. arg- The value.
debug(String, Object...)
public void debug(String format, Object... arguments)Writes a DEBUG line with any number of values.
Parameters
format- The line, with a
{}for each value. arguments- The values.
debug(String, Throwable)
public void debug(String msg, Throwable t)Writes a DEBUG line and an error's stack trace.
Parameters
msg- The line.
t- The error. Its stack trace is written after the line.
debug(String, Object, Object)
public void debug(String format, Object arg1, Object arg2)Writes a DEBUG line with two values.
Parameters
format- The line, with two
{}. arg1- The first value.
arg2- The second value.
error(String)
public void error(String msg)Writes a ERROR line: something failed.
Parameters
msg- The line.
error(String, Object)
public void error(String format, Object arg)Writes a ERROR line with one value.
Parameters
format- The line, with
{}where the value goes. arg- The value.
error(String, Object...)
public void error(String format, Object... arguments)Writes a ERROR line with any number of values.
Parameters
format- The line, with a
{}for each value. arguments- The values.
error(String, Throwable)
public void error(String msg, Throwable t)Writes a ERROR line and an error's stack trace.
Parameters
msg- The line.
t- The error. Its stack trace is written after the line.
error(String, Object, Object)
public void error(String format, Object arg1, Object arg2)Writes a ERROR line with two values.
Parameters
format- The line, with two
{}. arg1- The first value.
arg2- The second value.
getName()
public String getName()The logger's name: the class you made it for.
Returns
The name.
info(String)
public void info(String msg)Writes a INFO line: normal progress.
Parameters
msg- The line.
info(String, Object)
public void info(String format, Object arg)Writes a INFO line with one value.
Parameters
format- The line, with
{}where the value goes. arg- The value.
info(String, Object...)
public void info(String format, Object... arguments)Writes a INFO line with any number of values.
Parameters
format- The line, with a
{}for each value. arguments- The values.
info(String, Throwable)
public void info(String msg, Throwable t)Writes a INFO line and an error's stack trace.
Parameters
msg- The line.
t- The error. Its stack trace is written after the line.
info(String, Object, Object)
public void info(String format, Object arg1, Object arg2)Writes a INFO line with two values.
Parameters
format- The line, with two
{}. arg1- The first value.
arg2- The second value.
isDebugEnabled()
public boolean isDebugEnabled()Whether DEBUG lines are written.
Returns
true if they are. Skip building a costly value when it is false.
isErrorEnabled()
public boolean isErrorEnabled()Whether ERROR lines are written.
Returns
true if they are. Skip building a costly value when it is false.
isInfoEnabled()
public boolean isInfoEnabled()Whether INFO lines are written.
Returns
true if they are. Skip building a costly value when it is false.
isTraceEnabled()
public boolean isTraceEnabled()Whether TRACE lines are written.
Returns
true if they are. Skip building a costly value when it is false.
isWarnEnabled()
public boolean isWarnEnabled()Whether WARN lines are written.
Returns
true if they are. Skip building a costly value when it is false.
trace(String)
public void trace(String msg)Writes a TRACE line: the finest detail, hidden unless you turn it on.
Parameters
msg- The line.
trace(String, Object)
public void trace(String format, Object arg)Writes a TRACE line with one value.
Parameters
format- The line, with
{}where the value goes. arg- The value.
trace(String, Object...)
public void trace(String format, Object... arguments)Writes a TRACE line with any number of values.
Parameters
format- The line, with a
{}for each value. arguments- The values.
trace(String, Throwable)
public void trace(String msg, Throwable t)Writes a TRACE line and an error's stack trace.
Parameters
msg- The line.
t- The error. Its stack trace is written after the line.
trace(String, Object, Object)
public void trace(String format, Object arg1, Object arg2)Writes a TRACE line with two values.
Parameters
format- The line, with two
{}. arg1- The first value.
arg2- The second value.
warn(String)
public void warn(String msg)Writes a WARN line: something unexpected that the plugin handled.
Parameters
msg- The line.
warn(String, Object)
public void warn(String format, Object arg)Writes a WARN line with one value.
Parameters
format- The line, with
{}where the value goes. arg- The value.
warn(String, Object...)
public void warn(String format, Object... arguments)Writes a WARN line with any number of values.
Parameters
format- The line, with a
{}for each value. arguments- The values.
warn(String, Throwable)
public void warn(String msg, Throwable t)Writes a WARN line and an error's stack trace.
Parameters
msg- The line.
t- The error. Its stack trace is written after the line.
warn(String, Object, Object)
public void warn(String format, Object arg1, Object arg2)Writes a WARN line with two values.
Parameters
format- The line, with two
{}. arg1- The first value.
arg2- The second value.