Skip to content

Commit fdd81f4

Browse files
committed
Update readme logging
1 parent 4fee0d2 commit fdd81f4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ try (LlamaModel model = new LlamaModel(modelParams)) {
223223
}
224224
```
225225

226+
### Logging
227+
228+
Per default, logs are written to stdout.
229+
This can be intercepted via the static method `LlamaModel.setLogger(LogFormat, BiConsumer<LogLevel, String>)`.
230+
There is text- and JSON-based logging. The default is JSON.
231+
To only change the log format while still writing to stdout, `null` can be passed for the callback.
232+
Logging can be disabled by passing an empty callback.
233+
234+
```java
235+
// Re-direct log messages however you like (e.g. to a logging library)
236+
LlamaModel.setLogger(LogFormat.TEXT, (level, message) -> System.out.println(level.name() + ": " + message));
237+
// Log to stdout, but change the format
238+
LlamaModel.setLogger(LogFormat.TEXT, null);
239+
// Disable logging by passing a no-op
240+
LlamaModel.setLogger(null, (level, message) -> {});
241+
```
242+
226243
## Importing in Android
227244

228245
You can use this library in Android project.

0 commit comments

Comments
 (0)