Skip to content

Commit 030071e

Browse files
committed
add usage to readme
1 parent 6873f6f commit 030071e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,73 @@ A java library used to list and share log files to the [mclo.gs](https://mclo.gs
55
- Remove IPv4 and IPv6 addresses before uploading the log
66
- Trim logs and shorten them to 10 MB before uploading
77

8+
### Usage
9+
This project is available from Maven Central, so you just need to add the dependency to your project:
10+
11+
#### Gradle
12+
```gradle
13+
dependencies {
14+
implementation 'gs.mclo:api:3.0.0'
15+
}
16+
```
17+
18+
#### Maven
19+
```xml
20+
<dependency>
21+
<groupId>gs.mclo</groupId>
22+
<artifactId>api</artifactId>
23+
<version>3.0.0</version>
24+
</dependency>
25+
```
26+
27+
### Upload a log file
28+
29+
Obtaining a log file:
30+
```java
31+
// by path
32+
var log = new Log(Paths.get("./logs/latest.log"));
33+
// or by raw content
34+
log = new Log("example content");
35+
```
36+
37+
Creating a client:
38+
```java
39+
// Create a client with a project name and version
40+
var client = new MclogsClient("mclogs-java-example", "1.0.0");
41+
// optionally with a minecraft version
42+
client = new MclogsClient("mclogs-java-example", "1.0.0", "1.12.2");
43+
// or with a custom user agent
44+
client = new MclogsClient("mclogs-java-example/1.0.0");
45+
```
46+
47+
Sharing the log file:
48+
```java
49+
// share the log file
50+
var apiResponse = client.uploadLog(log);
51+
System.out.println(apiResponse.getUrl());
52+
```
53+
54+
There are also shortcuts for posting raw content or a path:
55+
```java
56+
// share a log file by path
57+
var apiResponse = client.uploadLog(Paths.get("./logs/latest.log"));
58+
// share a log file by raw content
59+
apiResponse = client.uploadLog("example content");
60+
```
61+
62+
### Fetch a log file's contents
63+
```java
64+
String secondResponse = client.getRawLogContent("HpAwPry");
65+
```
66+
67+
### Using a self-hosted instance of mclogs
68+
```java
69+
Instance instance = new Instance();
70+
instance.setApiBaseUrl("https://api.logs.example.com");
71+
instance.setViewLogUrl("https://api.logs.example.com");
72+
client.setInstance(instance);
73+
```
74+
875
This library is used in the mclogs plugin and mods:
976
[Bukkit](https://github.com/aternosorg/mclogs-bukkit) |
1077
[Forge](https://github.com/aternosorg/mclogs-forge) |

0 commit comments

Comments
 (0)