diff --git a/config/logback.xml b/config/logback.xml index 9fe5f368..6672ec07 100644 --- a/config/logback.xml +++ b/config/logback.xml @@ -1,4 +1,6 @@ + + @@ -9,7 +11,7 @@ 10 - %-25(%d{yyyyMMdd HHmmss.SSS} [%thread]) %-5level %logger{30} - %msg%n + %-25(%d{yyyyMMdd HHmmss.SSS} [%thread]) %-5level %logger{30} - %msg %memory_usage%n @@ -19,7 +21,7 @@ - %-12(%d{HH:mm:ss.SSS}) %-5level %logger{25} - %msg%n + %-12(%d{HH:mm:ss.SSS}) %-5level %logger{25} - %msg %memory_usage%n diff --git a/src/audio/broadcast/BroadcastState.java b/src/audio/broadcast/BroadcastState.java index 5e6d95ec..86470632 100644 --- a/src/audio/broadcast/BroadcastState.java +++ b/src/audio/broadcast/BroadcastState.java @@ -68,7 +68,7 @@ public enum BroadcastState /** * Specified mount point is already in use */ - MOUNT_POINT_IN_USE("Mount Point In Use", true), + MOUNT_POINT_IN_USE("Mount Point In Use", false), /** * Server is not known or reachable diff --git a/src/audio/broadcast/icecast/IcecastTCPAudioBroadcaster.java b/src/audio/broadcast/icecast/IcecastTCPAudioBroadcaster.java index 9d37c2e5..3d03e295 100644 --- a/src/audio/broadcast/icecast/IcecastTCPAudioBroadcaster.java +++ b/src/audio/broadcast/icecast/IcecastTCPAudioBroadcaster.java @@ -325,6 +325,10 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster { setBroadcastState(BroadcastState.MOUNT_POINT_IN_USE); } + else if(message.contains("Content-Type: text/html")) + { + //Disregard ... this normally follows the mount point in use error + } else if(message.contains("Invalid Password") || message.contains("Authentication Required")) { diff --git a/src/gui/SDRTrunk.java b/src/gui/SDRTrunk.java index 401067f6..9f3b4e06 100644 --- a/src/gui/SDRTrunk.java +++ b/src/gui/SDRTrunk.java @@ -33,6 +33,7 @@ import icon.IconManager; import map.MapService; import module.log.EventLogManager; import net.miginfocom.swing.MigLayout; +import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import playlist.PlaylistManager; @@ -80,16 +81,16 @@ public class SDRTrunk implements Listener public SDRTrunk() { - mLog.info(""); mLog.info("*******************************************************************"); mLog.info("**** sdrtrunk: a trunked radio and digital decoding application ***"); mLog.info("**** website: https://github.com/dsheirer/sdrtrunk ***"); mLog.info("*******************************************************************"); - mLog.info(""); - mLog.info("Host CPU Cores: " + Runtime.getRuntime().availableProcessors()); - mLog.info("Host Memory Total: " + Runtime.getRuntime().totalMemory()); - mLog.info("Host Memory Max: " + Runtime.getRuntime().maxMemory()); - mLog.info("Host Memory Free: " + Runtime.getRuntime().freeMemory()); + mLog.info("Memory Logging Format: [Used/Allocated PercentUsed%]"); + mLog.info("Host CPU Cores: " + Runtime.getRuntime().availableProcessors()); + mLog.info("Host OS Name: " + System.getProperty("os.name")); + mLog.info("Host OS Arch: " + System.getProperty("os.arch")); + mLog.info("Host OS Version: " + System.getProperty("os.version")); + mLog.info("Host Max Java Memory: " + FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())); //Setup the application home directory Path home = getHomePath(); diff --git a/src/util/MemoryUsageLogger.java b/src/util/MemoryUsageLogger.java new file mode 100644 index 00000000..df816e9c --- /dev/null +++ b/src/util/MemoryUsageLogger.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * sdrtrunk + * Copyright (C) 2014-2017 Dennis Sheirer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + * + ******************************************************************************/ +package util; + +import ch.qos.logback.classic.pattern.ClassicConverter; +import ch.qos.logback.classic.spi.ILoggingEvent; +import org.apache.commons.io.FileUtils; + +/** + * Custom logging plugin for logging memory usage with logback + * + * Add the following to the logback.xml configuration file to use this custom converter: + * + * + * + * Update the encoder pattern to include %memory_usage within the pattern + */ +public class MemoryUsageLogger extends ClassicConverter +{ + @Override + public String convert(ILoggingEvent iLoggingEvent) + { + //Method argument is ignored - we simply return memory usage statistics + long allocated = Runtime.getRuntime().totalMemory(); + long free = Runtime.getRuntime().freeMemory(); + long used = allocated - free; + + int usedPercentage = (int)((double)(used) / (double)allocated * 100.0); + + StringBuilder sb = new StringBuilder(); + + sb.append("[").append(FileUtils.byteCountToDisplaySize(used).replace(" ", "")); + sb.append("/").append(FileUtils.byteCountToDisplaySize(allocated).replace(" ", "")); + sb.append(" ").append(usedPercentage).append("%]"); + + return sb.toString(); + } +}