Skip to content

Commit

Permalink
Add support for WC24_DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Sep 14, 2024
1 parent 2e8bdff commit 204b96a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Adding `&format=json` to most search pages in the webapp will give you a JSON eq
* WII_FALLBACK: Wii Friend Code that will receive Wii Mail forwarded from DoujinSoft.
* WC24_SERVER: WiiConnect24 server URL. Currently, there's only really `rc24.xyz`...
* WC24_PASSWORD: Password for the DoujinSoft WiiConnect24 account
* WC24_DEBUG: Add this variable to log additional Wii Mail data.
* DSOFT_PASS: Password for the Admin console.
* WEBHOOK_URL: URL for a webhook. This hook is hit whenever new content is uploaded to DoujinSoft.

Expand Down
35 changes: 21 additions & 14 deletions src/com/difegue/doujinsoft/wc24/WiiConnect24Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ public String sendMails(List<MailItem> mails) throws IOException {
HttpEntity formDataEntity = builder.build();
httppost.setEntity(formDataEntity);

/*
// Log full multipart request
// Commented out as it makes the logs gigantic
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.build().writeTo(baos);
log.log(Level.INFO, "Executing request:" + System.lineSeparator()
+ httppost.getRequestLine() + System.lineSeparator()
+ baos.toString());
}
catch (Exception e) {
log.log(Level.INFO, e.getMessage() );

// Log full multipart request, if thou must
// It makes the logs gigantic
if (System.getenv().containsKey("WC24_DEBUG")) {

try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
builder.build().writeTo(baos);

log.log(Level.INFO, "Executing request:" + System.lineSeparator()
+ httppost.getRequestLine() + System.lineSeparator()
+ baos.toString());
}
catch (Exception e) {
log.log(Level.INFO, e.getMessage() );
}
}
*/

// Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
Expand Down Expand Up @@ -121,6 +123,11 @@ public void receiveMails() throws Exception {
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();

if (System.getenv().containsKey("WC24_DEBUG")) {
Logger log = Logger.getLogger("WC24 Debug");
log.log(Level.INFO, responseText);
}

if (entity != null)
try (InputStream inStream = entity.getContent()) {

Expand Down

0 comments on commit 204b96a

Please sign in to comment.