Files
Iris/src/main/java/com/volmit/ModuleLog.java
T
piexel 1677f4414b Batch 1 of the API review: one setup entry point, per-pipeline definitions
- IrisModule.setup(ModuleSetup) replaces install(StageGraph) and
  register(FeatureRegistry); ModuleSetups.run is the host entry point.
- The conditional definition variants are gone: a stage body reads the
  settings it is conditioned on through ctx.configured(Type.class).
- Placement, block, chunk and mantle stages each get their own
  definition interface; chunk definitions offer neither reach nor
  writesMantle. MantleStage is no longer generic.
- softAfter/softBefore take stage constants as well as StageRefs.
- A producer that rejected the attempt may return null.
- PlacementRunner, ChunkRunner and MantleRunner all take StageTimings.
- ConfiguredSettings groups entries by the type that declares @Feature.
- README, DESIGN and CONTRACTS updated, with the edge choice table.
2026-10-23 13:00:07 +02:00

36 lines
2.0 KiB
Java

package com.volmit;
/** The log of one module. The host labels every line with the module's id, such as {@code [iris:decorant]}, and writes it
* to its own log, so a module never needs a logging library of its own and its lines are easy to find. Each module has
* its own: reach it as {@code context.log()} in stage bodies and generators
* ({@link com.volmit.generation.InvocationContext#log}), as {@link com.volmit.world.PackWorld#log} in services and
* lifecycle hooks, and as {@link ModuleSetup#log} during the module's setup.
*
* <p>Safe to use from any thread. A message is plain text, not a format string.
*/
public interface ModuleLog {
/** Detail for people debugging the module. The host writes it only when its debug setting is on, so building the
* message costs time even when nobody reads it: guard a message that is expensive to build, or leave it out.
*/
void debug(String message);
/** Something worth telling the server owner once in a while, such as what the module did at startup. */
void info(String message);
/** Something is wrong or unusual, but the module carries on. */
void warn(String message);
/** Warns the first time {@code key} is used on this log and writes {@code message} at {@link #debug} level every
* time after, for a condition worth stating once that is met per block, per sample or per chunk. Keys belong to the
* module: two modules can use the same key and each warns once. The key space must be bounded, so never put a
* coordinate in it; the host stops claiming new keys beyond a few hundred and then only debugs.
*/
void warnOnce(String key, String message);
/** Logs {@code message} as an error and reports {@code cause} the way the host reports its own failures, such as
* to its error tracker. Use it for a failure the module caught but cannot recover from. A null {@code cause}
* only logs the message.
*/
void error(String message, Throwable cause);
}