use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LogsITCase method searchLog.
private Component searchLog(final String property, final String searchPath, final String key) {
Component component = TESTER.getComponentFromLastRenderedPage(searchPath);
Component result = component.getPage().visitChildren(ListItem.class, (final ListItem<LoggerTO> object, final IVisit<Component> visit) -> {
try {
if (object.getModelObject() instanceof LoggerTO && PropertyResolver.getPropertyGetter(property, object.getModelObject()).invoke(object.getModelObject()).equals(key)) {
visit.stop(object);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
LOG.error("Error invoke method", ex);
}
});
return result;
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerDetails method details.
public void details() {
if (input.parameterNumber() == 0) {
try {
final Map<String, String> details = new LinkedHashMap<>();
final List<LoggerTO> loggerTOs = loggerSyncopeOperations.list();
int debugLevel = 0;
int errorLevel = 0;
int fatalLevel = 0;
int infoLevel = 0;
int offLevel = 0;
int traceLevel = 0;
int warnLevel = 0;
for (final LoggerTO loggerTO : loggerTOs) {
switch(loggerTO.getLevel()) {
case DEBUG:
debugLevel++;
break;
case ERROR:
errorLevel++;
break;
case FATAL:
fatalLevel++;
break;
case INFO:
infoLevel++;
break;
case OFF:
offLevel++;
break;
case TRACE:
traceLevel++;
break;
case WARN:
warnLevel++;
break;
default:
break;
}
}
details.put("Total number", String.valueOf(loggerTOs.size()));
details.put("Set to DEBUG", String.valueOf(debugLevel));
details.put("Set to ERROR", String.valueOf(errorLevel));
details.put("Set to FATAL", String.valueOf(fatalLevel));
details.put("Set to INFO", String.valueOf(infoLevel));
details.put("Set to OFF", String.valueOf(offLevel));
details.put("Set to TRACE", String.valueOf(traceLevel));
details.put("Set to WARN", String.valueOf(warnLevel));
loggerResultManager.printDetails(details);
} catch (final SyncopeClientException ex) {
LOG.error("Error reading details about logger", ex);
loggerResultManager.genericError(ex.getMessage());
}
} else {
loggerResultManager.unnecessaryParameters(input.listParameters(), LIST_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerUpdate method update.
public void update() {
if (input.parameterNumber() >= 1) {
final List<LoggerTO> loggerTOs = new ArrayList<>();
boolean failed = false;
for (String parameter : input.getParameters()) {
Pair<String, String> pairParameter = Input.toPairParameter(parameter);
try {
LoggerTO loggerTO = loggerSyncopeOperations.read(pairParameter.getKey());
loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue()));
loggerSyncopeOperations.update(loggerTO);
loggerTOs.add(loggerTO);
} catch (WebServiceException | SyncopeClientException | IllegalArgumentException ex) {
LOG.error("Error updating logger", ex);
if (ex.getMessage().startsWith("No enum constant org.apache.syncope.common.lib.types.")) {
loggerResultManager.typeNotValidError("logger level", input.firstParameter(), CommandUtils.fromEnumToArray(LoggerLevel.class));
} else if ("Parameter syntax error!".equalsIgnoreCase(ex.getMessage())) {
loggerResultManager.genericError(ex.getMessage());
loggerResultManager.genericError(UPDATE_HELP_MESSAGE);
} else if (ex.getMessage().startsWith("NotFound")) {
loggerResultManager.notFoundError("Logger", parameter);
} else {
loggerResultManager.genericError(ex.getMessage());
loggerResultManager.genericError(UPDATE_HELP_MESSAGE);
}
failed = true;
break;
}
}
if (!failed) {
loggerResultManager.fromUpdate(loggerTOs);
}
} else {
loggerResultManager.commandOptionError(UPDATE_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerUpdateAll method updateAll.
public void updateAll() {
if (input.parameterNumber() == 1) {
final List<LoggerTO> loggerTOs = new ArrayList<>();
boolean failed = false;
for (final LoggerTO loggerTO : loggerSyncopeOperations.list()) {
try {
loggerTO.setLevel(LoggerLevel.valueOf(input.firstParameter()));
loggerSyncopeOperations.update(loggerTO);
loggerTOs.add(loggerTO);
} catch (final WebServiceException | SyncopeClientException | IllegalArgumentException ex) {
LOG.error("Error updating logger", ex);
if (ex.getMessage().startsWith("No enum constant org.apache.syncope.common.lib.types.")) {
loggerResultManager.typeNotValidError("logger level", input.firstParameter(), CommandUtils.fromEnumToArray(LoggerLevel.class));
} else {
loggerResultManager.genericError(ex.getMessage());
loggerResultManager.genericError(UPDATE_ALL_HELP_MESSAGE);
}
failed = true;
break;
}
}
if (!failed) {
loggerResultManager.fromUpdate(loggerTOs);
}
} else {
loggerResultManager.commandOptionError(UPDATE_ALL_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerRestClient method enableAudit.
public void enableAudit(final AuditLoggerName auditLoggerName) {
LoggerTO loggerTO = new LoggerTO();
loggerTO.setKey(auditLoggerName.toLoggerName());
loggerTO.setLevel(LoggerLevel.DEBUG);
getService(LoggerService.class).update(LoggerType.AUDIT, loggerTO);
}
Aggregations