Skip to content

io7m-com/taskrecorder

Repository files navigation

taskrecorder

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.taskrecorder

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

taskrecorder

The taskrecorder package provides a simple abstraction to record the steps (and subtasks) performed during the execution of tasks within an application.

Features

  • Record detailed task steps for informative error reports.
  • High coverage test suite.
  • OSGi-ready
  • JPMS-ready
  • ISC license.

Usage

Create a new task, and create steps and subtasks as the application performs operations:

final Logger logger;
final TRTaskRecorderType<Integer> recorder =
  TRTaskRecorder.create(logger, "Book Flight");

recorder.beginStep("Picking best airline price...");
Airline airline;
try {
  airline = pickAirline();
  recorder.setStepSucceeded("Found airline.");
} catch (Exception e) {
  recorder.setTaskFailed("No price available.", e);
  return;
}

recorder.beginStep("Making reservation...");
try {
  int id = makeReservation(airline);
  recorder.setTaskSucceeded("Created reservation.", id);
} catch (Exception e) {
  recorder.setTaskFailed("No reservations available.", e);
  return;
}

var task = recorder.toTask();
assert task.resolution() instanceof TRSucceeded;