Search in sources :

Example 1 with LogStatementTO

use of org.apache.syncope.common.lib.log.LogStatementTO in project syncope by apache.

the class MemoryAppender method append.

@Override
public void append(final LogEvent event) {
    LogStatementTO statement = new LogStatementTO();
    statement.setLevel(LoggerLevel.fromLevel(event.getLevel()));
    statement.setLoggerName(event.getLoggerName());
    Message msg = event.getMessage();
    statement.setMessage((msg instanceof ReusableMessage ? ((ReusableMessage) msg).memento() : msg).getFormattedMessage());
    statement.setTimeMillis(event.getTimeMillis());
    if (event.getThrown() != null) {
        statement.setStackTrace(ExceptionUtils2.getFullStackTrace(event.getThrown()));
    }
    statement.setThreadId(event.getThreadId());
    statement.setThreadName(event.getThreadName());
    statement.setThreadPriority(event.getThreadPriority());
    this.statements.add(statement);
}
Also used : ReusableMessage(org.apache.logging.log4j.message.ReusableMessage) Message(org.apache.logging.log4j.message.Message) ReusableMessage(org.apache.logging.log4j.message.ReusableMessage) LogStatementTO(org.apache.syncope.common.lib.log.LogStatementTO)

Example 2 with LogStatementTO

use of org.apache.syncope.common.lib.log.LogStatementTO in project syncope by apache.

the class LoggerITCase method lastStatements.

@Test
public void lastStatements() {
    List<LogStatementTO> statements = loggerService.getLastLogStatements("connid");
    assertNotNull(statements);
    assertFalse(statements.isEmpty());
    LogStatementTO statement = statements.get(0);
    assertNotNull(statement);
    assertNotNull(statement.getLoggerName());
    assertNotNull(statement.getLevel());
    assertNotNull(statement.getMessage());
    assertNotNull(statement.getTimeMillis());
}
Also used : LogStatementTO(org.apache.syncope.common.lib.log.LogStatementTO) Test(org.junit.jupiter.api.Test)

Example 3 with LogStatementTO

use of org.apache.syncope.common.lib.log.LogStatementTO in project syncope by apache.

the class LoggerResultManager method fromGetLastLogStatements.

public void fromGetLastLogStatements(final List<LogStatementTO> statements) throws JsonProcessingException {
    final Table.TableBuilder tableBuilder = new Table.TableBuilder("last statements").header("statement");
    for (final LogStatementTO statement : statements) {
        tableBuilder.rowValues(Collections.singletonList(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(statement)));
    }
    tableBuilder.build().print();
}
Also used : Table(org.apache.syncope.client.cli.view.Table) LogStatementTO(org.apache.syncope.common.lib.log.LogStatementTO)

Aggregations

LogStatementTO (org.apache.syncope.common.lib.log.LogStatementTO)3 Message (org.apache.logging.log4j.message.Message)1 ReusableMessage (org.apache.logging.log4j.message.ReusableMessage)1 Table (org.apache.syncope.client.cli.view.Table)1 Test (org.junit.jupiter.api.Test)1