Add a delayed log method
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,6 +2,9 @@ package wtf.beatrice.hidekobot.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
@@ -28,4 +31,18 @@ public class Logger
|
||||
.replace("%class%", className)
|
||||
.replace("%message%", message));
|
||||
}
|
||||
|
||||
// log a message to console after delaying it (in seconds).
|
||||
public void log(String message, int delay)
|
||||
{
|
||||
Executors.newSingleThreadScheduledExecutor().schedule(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
log(message);
|
||||
}
|
||||
}, delay, TimeUnit.SECONDS);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user