125 lines
4.9 KiB
Java
125 lines
4.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.tridium.sys.spy;
|
|
|
|
import javax.baja.log.Log;
|
|
import javax.baja.spy.ISpyDir;
|
|
import javax.baja.spy.Spy;
|
|
import javax.baja.spy.SpyWriter;
|
|
import javax.baja.sys.BAbsTime;
|
|
|
|
public class LogSetupSpy
|
|
extends Spy
|
|
implements ISpyDir {
|
|
private static final Log log = Log.getLog("sys");
|
|
|
|
public String[] list() {
|
|
return new String[0];
|
|
}
|
|
|
|
public Spy find(String string) {
|
|
String string2 = string;
|
|
String string3 = null;
|
|
int n = string.indexOf(45);
|
|
if (n > 0) {
|
|
string2 = string.substring(0, n);
|
|
string3 = string.substring(n + 1);
|
|
}
|
|
if (string2.equals("save")) {
|
|
return this.save();
|
|
}
|
|
if (string2.equals("trace")) {
|
|
return this.change(string3, 0);
|
|
}
|
|
if (string2.equals("message")) {
|
|
return this.change(string3, 1);
|
|
}
|
|
if (string2.equals("warning")) {
|
|
return this.change(string3, 2);
|
|
}
|
|
if (string2.equals("error")) {
|
|
return this.change(string3, 3);
|
|
}
|
|
if (string2.equals("none")) {
|
|
return this.change(string3, 4);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void write(SpyWriter spyWriter) {
|
|
spyWriter.startTable(true);
|
|
spyWriter.trTitle("Logs [<a href='spy:/logSetup/" + this.cmdToHref("save", null) + "'>Save To File</a>]", 7);
|
|
spyWriter.w("<tr><th align='left'>log.properties</th><td align='left' colspan='6'>").w(BAbsTime.make(Log.getLogFile().lastModified())).w("</td></tr>\n");
|
|
spyWriter.w("<tr>");
|
|
spyWriter.thTitle("Log").thTitle("Level").thTitle("<a color='black' href='spy:/logSetup/" + this.cmdToHref("trace", null) + "'>Trace</a>").thTitle("<a color='black' href='spy:/logSetup/" + this.cmdToHref("message", null) + "'>Message</a>").thTitle("<a color='black' href='spy:/logSetup/" + this.cmdToHref("warning", null) + "'>Warning</a>").thTitle("<a color='black' href='spy:/logSetup/" + this.cmdToHref("error", null) + "'>Error</a>").thTitle("<a color='black' href='spy:/logSetup/" + this.cmdToHref("none", null) + "'>None</a>").w("</tr>");
|
|
Log[] logArray = Log.getLogs();
|
|
int n = 0;
|
|
while (n < logArray.length) {
|
|
Log log = logArray[n];
|
|
String string = log.getLogName();
|
|
int n2 = log.getSeverity();
|
|
String string2 = n2 == 0 ? "[X]" : "[<a href='spy:/logSetup/" + this.cmdToHref("trace", string) + "'>_</a>]";
|
|
String string3 = n2 == 1 ? "[X]" : "[<a href='spy:/logSetup/" + this.cmdToHref("message", string) + "'>_</a>]";
|
|
String string4 = n2 == 2 ? "[X]" : "[<a href='spy:/logSetup/" + this.cmdToHref("warning", string) + "'>_</a>]";
|
|
String string5 = n2 == 3 ? "[X]" : "[<a href='spy:/logSetup/" + this.cmdToHref("error", string) + "'>_</a>]";
|
|
String string6 = n2 == 4 ? "[X]" : "[<a href='spy:/logSetup/" + this.cmdToHref("none", string) + "'>_</a>]";
|
|
spyWriter.w("<tr>");
|
|
spyWriter.w("<td align='left' nowrap='true'>").w(string).w("</td>");
|
|
spyWriter.w("<td align='left' nowrap='true'>").w(log.getSeverityString()).w("</td>");
|
|
spyWriter.w("<td align='center' nowrap='true'>").w(string2).w("</td>");
|
|
spyWriter.w("<td align='center' nowrap='true'>").w(string3).w("</td>");
|
|
spyWriter.w("<td align='center' nowrap='true'>").w(string4).w("</td>");
|
|
spyWriter.w("<td align='center' nowrap='true'>").w(string5).w("</td>");
|
|
spyWriter.w("<td align='center' nowrap='true'>").w(string6).w("</td>");
|
|
spyWriter.w("</tr>\n");
|
|
++n;
|
|
}
|
|
spyWriter.endTable();
|
|
}
|
|
|
|
public String cmdToHref(String string, String string2) {
|
|
if (string2 == null) {
|
|
return string;
|
|
}
|
|
return string + '-' + string2;
|
|
}
|
|
|
|
public Spy save() {
|
|
log.message("Saved 'log.properties'.");
|
|
Log.save();
|
|
return new MessageLogSetupSpy("Saved 'log.properties' file");
|
|
}
|
|
|
|
public Spy change(String string, int n) {
|
|
if (string != null) {
|
|
Log.getLog(string).setSeverity(n);
|
|
return new MessageLogSetupSpy("Changed " + string + " log to level '" + Log.severityToString(n) + "'.");
|
|
}
|
|
Log[] logArray = Log.getLogs();
|
|
int n2 = 0;
|
|
while (n2 < logArray.length) {
|
|
logArray[n2].setSeverity(n);
|
|
++n2;
|
|
}
|
|
return new MessageLogSetupSpy("All logs changed to level '" + Log.severityToString(n) + "'.");
|
|
}
|
|
|
|
private static class MessageLogSetupSpy
|
|
extends LogSetupSpy {
|
|
String message;
|
|
|
|
public void write(SpyWriter spyWriter) {
|
|
spyWriter.write("<br><b>");
|
|
spyWriter.write(this.message);
|
|
spyWriter.write("</b><br><br>");
|
|
super.write(spyWriter);
|
|
}
|
|
|
|
public MessageLogSetupSpy(String string) {
|
|
this.message = string;
|
|
}
|
|
}
|
|
}
|
|
|