# Elevator Logging Utility

Elevators provides a built-in logging system through the Elevators class, designed to make structured console output easier and more readable.


# Basic Logging

Use Elevators.log(String message) to print a message to the console prefixed under the plugin’s name.

Elevators.log("Hello, how are you doing?");

Console output:

[Elevators] Hello, how are you doing?

# Log Stack: Indentation

You can create hierarchical/indented logging output using a stack-style logging system.

pushLog() and popLog()

Elevators.log("Hello");

Elevators.pushLog();
Elevators.log("This is indented");

Elevators.pushLog();
Elevators.log("This is indented even more");

Elevators.popLog();
Elevators.popLog();

Elevators.log("Back to normal");

Console output:

[Elevators] Hello
[Elevators] 	This is indented
[Elevators] 		This is indented even more
[Elevators] Back to normal

# Holding Logs Temporarily

You can delay output to the console using the hold/release system.

holdLog() and releaseLog()

Elevators.holdLog();
Elevators.log("Message 1");
Elevators.log("Message 2");
Elevators.releaseLog();

pushAndHoldLog() is a shortcut for combining pushLog() and holdLog().
popLog() will call releaseLog() if the current stack is being withheld.

Output appears after releaseLog() is called and will respect the current contexts indention.


# Tracking Hold Durations

popLog() and releaseLog will both return an instance of LogReleaseData which details the logs and how long a section of logs took in milliseconds:

Elevators.log("Starting process");
Elevators.pushAndHoldLog();

Elevators.log("This is indented");
// some process here...
Elevators.log("This is also indented");

LogReleaseData logData = Elevators.popLog();
Elevators.log("Process completed in " + logData.getElapsedTime() + "ms");

Console output:

[Elevators] Starting process
[Elevators] 	This is indented
[Elevators] 	This is also indented
[Elevators] Process completed in 0ms

You can use the Consumer overloads found in the two methods to execute code prior to the logging being sent in console:

Elevators.pushAndHoldLog();

Elevators.log("This is indented");
// some process here...
Elevators.log("This is also indented");

Elevators.popLog((logData) -> {
    Elevators.log("Process completed in " + logData.getElapsedTime() + "ms:");
});

Console output:

[Elevators] Process completed in 0ms:
[Elevators] 	This is indented
[Elevators] 	This is also indented

# LogReleaseData

The LogReleaseData object contains the following methods:

  • getLogs() – a list of all held log messages. This will contain tabulated indention characters, so you may need to trim depending on your use.
  • getElapsedTime() – time in milliseconds since the stack was held. If the stack was never held, this will return 0.

# Summary

Method Description
log(String) Prints a message to console with Elevators prefix
pushLog() / popLog() Indents log output for readability
holdLog() / releaseLog() Temporarily queues log output
pushAndHoldLog() Shortcut for pushLog() + holdLog()
popLog(Consumer) / releaseLog(Consumer) Pops or releases current queue and allows pre-log execution