From b2d3025c1ef2e63b58026dfc4d0b318565aa681a Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Tue, 25 Jun 2024 14:05:15 +0200 Subject: [PATCH] avoiding crashes --- .../main/java/org/cagnulein/android_remote/FileLogger.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/cagnulein/android_remote/FileLogger.java b/app/src/main/java/org/cagnulein/android_remote/FileLogger.java index 95ecc18..a252bc2 100644 --- a/app/src/main/java/org/cagnulein/android_remote/FileLogger.java +++ b/app/src/main/java/org/cagnulein/android_remote/FileLogger.java @@ -36,8 +36,10 @@ public void log(Level level, String msg) { super.log(level, msg); if(true/*debuglog*/) { try { - writer.write(String.format("[%s] %s: %s%n", java.time.LocalDateTime.now(), level, msg)); - writer.flush(); + if(writer != null) { + writer.write(String.format("[%s] %s: %s%n", java.time.LocalDateTime.now(), level, msg)); + writer.flush(); + } } catch (IOException e) { e.printStackTrace(); }