Skip to content

Commit

Permalink
Make wc24 debug logging more convenient to use
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Sep 14, 2024
1 parent 5b78a14 commit 19292a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/com/difegue/doujinsoft/wc24/WC24Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class WC24Base {

protected String sender, wc24Server, wc24Pass;
protected Boolean debugLogging;
protected ServletContext application;

public WC24Base(ServletContext application) throws Exception {
Expand All @@ -24,6 +25,11 @@ public WC24Base(ServletContext application) throws Exception {
throw new Exception(
"WiiConnect24 account password not specified. Please set the WC24_PASSWORD environment variable.");

if (!System.getenv().containsKey("WC24_DEBUG"))
debugLogging = false;
else
debugLogging = Boolean.parseBoolean(System.getenv("DEBUG_LOGGING"));

sender = System.getenv("WII_NUMBER");
wc24Server = System.getenv("WC24_SERVER");
wc24Pass = System.getenv("WC24_PASSWORD");
Expand Down
4 changes: 2 additions & 2 deletions src/com/difegue/doujinsoft/wc24/WiiConnect24Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private String sendMailsInternal(List<MailItem> mails) throws IOException {

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

try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand Down Expand Up @@ -147,7 +147,7 @@ public void receiveMails() throws Exception {
String responseText = new BufferedReader(new InputStreamReader(inStream)).lines()
.collect(Collectors.joining("\n"));

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

0 comments on commit 19292a9

Please sign in to comment.