A java library used to list and share log files to the mclo.gs API.
- Remove IPv4 and IPv6 addresses before uploading the log
- Trim logs and shorten them to 10 MB before uploading
This project is available from Maven Central, so you just need to add the dependency to your project:
dependencies {
implementation 'gs.mclo:api:4.0.4'
}
<dependency>
<groupId>gs.mclo</groupId>
<artifactId>api</artifactId>
<version>4.0.4</version>
</dependency>
Obtaining a log file:
// by path
var log = new Log(Paths.get("./logs/latest.log"));
// or by raw content
log = new Log("example content");
Creating a client:
// Create a client with a project name and version
var client = new MclogsClient("mclogs-java-example", "1.0.0");
// optionally with a minecraft version
client = new MclogsClient("mclogs-java-example", "1.0.0", "1.12.2");
// or with a custom user agent
client = new MclogsClient("mclogs-java-example/1.0.0");
Sharing the log file:
// share the log file
CompletableFuture<UploadLogResponse> future = client.uploadLog(log);
UploadLogResponse response = future.get();
System.out.println(response.getUrl());
There are also shortcuts for posting raw content or a path:
// share a log file by path
CompletableFuture<UploadLogResponse> future = client.uploadLog(Paths.get("./logs/latest.log"));
// share a log file by raw content
future = client.uploadLog("example content");
String secondResponse = client.getRawLogContent("HpAwPry").get();
Instance instance = new Instance();
instance.setApiBaseUrl("https://api.logs.example.com");
instance.setViewLogUrl("https://api.logs.example.com");
client.setInstance(instance);
This library is used in the mclogs plugin and mods: Bukkit | Forge | Fabric