Skip to content

Commit

Permalink
adding logging note to README
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Nov 12, 2023
1 parent c62433a commit d1096b6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![](https://img.shields.io/github/discussions/CJCrafter/ChatGPT-Java-API)](https://github.com/CJCrafter/ChatGPT-Java-API/discussions)
[![License](https://img.shields.io/github/license/CJCrafter/ChatGPT-Java-API)](https://github.com/CJCrafter/ChatGPT-Java-API/blob/master/LICENSE)

A community-maintained easy-to-use Java/Kotlin OpenAI API for ChatGPT, Text Completions, and more!
An unofficial, easy-to-use Java/Kotlin OpenAI API for ChatGPT, Text Completions, and more!
</div>

## Features
Expand Down Expand Up @@ -96,6 +96,34 @@ For more examples, check out [examples](https://github.com/CJCrafter/ChatGPT-Jav
> **Note**: OpenAI recommends using environment variables for your API token
([Read more](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)).

## Logging
We use [SLF4J](http://www.slf4j.org/) for logging. To enable logging, add a logging implementation to your project.
If you encounter an issue with the JSON parsing, we will ask that you enable logging and send us the logs.

Adding a logging implementation:
```kotlin
implementation("ch.qos.logback:logback-classic:$version")
```

Add a `logback.xml` file to your resources folder:
```xml
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>debug.log</file>
<append>false</append>
<encoder>
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
</encoder>
</appender>

<logger name="com.cjcrafter.openai" level="DEBUG"/> <!-- Change to OFF to disable our logging -->

<root level="DEBUG">
<appender-ref ref="FILE"/>
</root>
</configuration>
```

## Support
If I have saved you time, please consider [sponsoring me](https://github.com/sponsors/CJCrafter).

Expand Down
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseTask

group = "com.cjcrafter"
version = "2.0.0"
version = "2.0.1"

plugins {
`java-library`
`maven-publish`
signing
id("io.codearte.nexus-staging") version "0.30.0"
kotlin("jvm") version "1.7.20-RC"
kotlin("jvm") version "1.9.20"
id("org.jetbrains.dokka") version "1.8.10" // KDoc Documentation Builder
id("com.github.breadmoirai.github-release") version "2.4.1"
}
Expand All @@ -18,7 +18,7 @@ repositories {
}

dependencies {
implementation("com.squareup.okhttp3:okhttp:4.9.2")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

implementation("com.fasterxml.jackson.core:jackson-core:2.15.3")
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3")
Expand All @@ -31,8 +31,8 @@ dependencies {

testImplementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
testImplementation("com.squareup.okhttp3:okhttp:4.9.2")
testImplementation("com.squareup.okhttp3:mockwebserver:4.9.2")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
}

kotlin {
Expand Down
4 changes: 2 additions & 2 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version "1.7.20-RC"
kotlin("jvm") version "1.9.20"
}

repositories {
Expand All @@ -9,7 +9,7 @@ repositories {

dependencies {
implementation(project(":"))
implementation("com.squareup.okhttp3:okhttp:4.9.2")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.fasterxml.jackson.core:jackson-core:2.15.3")
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.3")
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
Expand Down
2 changes: 2 additions & 0 deletions examples/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</encoder>
</appender>

<logger name="com.cjcrafter.openai" level="DEBUG"/>

<root level="DEBUG">
<appender-ref ref="FILE"/>
</root>
Expand Down

0 comments on commit d1096b6

Please sign in to comment.