Small updates
This commit is contained in:
parent
c894ba8a61
commit
31ab57dec1
3 changed files with 23 additions and 8 deletions
|
|
@ -153,10 +153,13 @@ public class CompactLogFormatter extends Formatter{
|
|||
*/
|
||||
private String paddClassName(String source){
|
||||
String cStr = padd_cache.get(source);
|
||||
if(cStr == null || cStr.length() != max_class_name) {
|
||||
if (cStr == null || cStr.length() != max_class_name) {
|
||||
cStr = source.substring(source.lastIndexOf('.') + 1); // Remove packages
|
||||
if(cStr.lastIndexOf('$') >= 0) // extract subclass name
|
||||
cStr = cStr.substring(cStr.lastIndexOf('$')+1);
|
||||
if (cStr.lastIndexOf('$') >= 0) { // extract subclass name
|
||||
String subClass = cStr.substring(cStr.lastIndexOf('$') + 1);
|
||||
if (!Pattern.matches("\\d+", subClass)) // Don'n substring for anonymous classes
|
||||
cStr = subClass;
|
||||
}
|
||||
|
||||
if (cStr.length() > max_class_name)
|
||||
max_class_name = cStr.length();
|
||||
|
|
|
|||
|
|
@ -26,9 +26,12 @@ package zutil.log;
|
|||
|
||||
import zutil.io.file.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.logging.*;
|
||||
|
||||
import static java.lang.System.in;
|
||||
|
||||
/**
|
||||
* Utility functions for the standard Java Logger
|
||||
*
|
||||
|
|
@ -130,11 +133,16 @@ public class LogUtil {
|
|||
|
||||
public static void readConfiguration(String file){
|
||||
try{
|
||||
FileInputStream in = new FileInputStream(FileUtil.find(file));
|
||||
File confFile = FileUtil.find(file);
|
||||
if (confFile != null) {
|
||||
FileInputStream in = new FileInputStream(confFile);
|
||||
LogManager.getLogManager().readConfiguration(in);
|
||||
in.close();
|
||||
}
|
||||
else
|
||||
logger.warning("Unable to find logging configuration file: "+file);
|
||||
} catch (Exception e){
|
||||
logger.log(Level.SEVERE, null, e);
|
||||
logger.log(Level.SEVERE, "Unable to load logging configuration: "+file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public class NutUPSClient {
|
|||
private static final String PARAMETER_POWER_LOAD = "ups.load"; //ups.power
|
||||
private static final String PARAMETER_POWER_USAGE = "ups.realpower"; //ups.power
|
||||
private static final String PARAMETER_BATTERY_CHARGE = "battery.charge";
|
||||
private static final String PARAMETER_BATTERY_VOLTAGE = "battery.voltage";
|
||||
private static final String PARAMETER_POLL_INTERVAL = "driver.parameter.pollinterval";
|
||||
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ public class NutUPSClient {
|
|||
|
||||
protected synchronized void update(){
|
||||
if(pollTimer.hasTimedOut()){
|
||||
logger.fine("Starting UPS data refresh");
|
||||
logger.fine("Starting UPS data refresh ("+host+":"+port+")");
|
||||
try(Socket s = new Socket(host, port)) {
|
||||
Writer out = new OutputStreamWriter(s.getOutputStream());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
|
||||
|
|
@ -162,6 +163,9 @@ public class NutUPSClient {
|
|||
public int getBatteryCharge(){
|
||||
return Integer.parseInt(parameters.get(PARAMETER_BATTERY_CHARGE));
|
||||
}
|
||||
public double getBatteryVoltage(){
|
||||
return Double.parseDouble(parameters.get(PARAMETER_BATTERY_VOLTAGE));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue