* configlogging.jsp:

- Add easy way to add an override
      - Make file size specifier more flexible
This commit is contained in:
zzz
2010-10-07 18:39:03 +00:00
parent 86a7d68f08
commit a23ea5e5f1
4 changed files with 118 additions and 27 deletions

View File

@@ -17,6 +17,8 @@ public class ConfigLoggingHandler extends FormHandler {
private String _recordFormat;
private String _dateFormat;
private String _fileSize;
private String _newLogClass;
private String _newLogLevel = "WARN";
@Override
protected void processForm() {
@@ -26,7 +28,7 @@ public class ConfigLoggingHandler extends FormHandler {
// noop
}
}
public void setShouldsave(String moo) { _shouldSave = true; }
public void setLevels(String levels) {
@@ -47,6 +49,18 @@ public class ConfigLoggingHandler extends FormHandler {
public void setLogfilesize(String size) {
_fileSize = (size != null ? size.trim() : null);
}
/** @since 0.8.1 */
public void setNewlogclass(String s) {
if (s != null && s.length() > 0)
_newLogClass = s;
}
/** @since 0.8.1 */
public void setNewloglevel(String s) {
if (s != null)
_newLogLevel = s;
}
/**
* The user made changes to the config and wants to save them, so
@@ -56,14 +70,18 @@ public class ConfigLoggingHandler extends FormHandler {
private void saveChanges() {
boolean shouldSave = false;
if (_levels != null) {
if (_levels != null || _newLogClass != null) {
try {
Properties props = new Properties();
props.load(new ByteArrayInputStream(_levels.getBytes()));
if (_levels != null)
props.load(new ByteArrayInputStream(_levels.getBytes()));
if (_newLogClass != null)
props.setProperty(_newLogClass, _newLogLevel);
_context.logManager().setLimits(props);
shouldSave = true;
addFormNotice("Log limits updated");
addFormNotice(_("Log overrides updated"));
} catch (IOException ioe) {
// shouldn't ever happen (BAIS shouldnt cause an IOE)
_context.logManager().getLog(ConfigLoggingHandler.class).error("Error reading from the props?", ioe);
addFormError("Error updating the log limits - levels not valid");
}
@@ -83,7 +101,7 @@ public class ConfigLoggingHandler extends FormHandler {
}
}
if (_dateFormat != null) {
if (_dateFormat != null && !_dateFormat.equals(_context.logManager().getDateFormatPattern())) {
boolean valid = _context.logManager().setDateFormat(_dateFormat);
if (valid) {
shouldSave = true;
@@ -139,7 +157,7 @@ public class ConfigLoggingHandler extends FormHandler {
boolean saved = _context.logManager().saveConfig();
if (saved)
addFormNotice("Log configuration saved and applied successfully");
addFormNotice(_("Log configuration saved"));
else
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
}