LogEntry toLogEntry() { return new LogEntry(level, timestamp, message); }
public void publish(LogRecord record) { LogEntry entry = new LogEntry(record.getLevel(), System.currentTimeMillis(), record.getMessage()); logs.addEntry(LogType.DRIVER, entry); }
@Override public synchronized void publish(LogRecord logRecord) { if (isLoggable(logRecord)) { if (records.size() > MAX_RECORDS) { records.remove(); } records.add(new LogEntry(logRecord.getLevel(), logRecord.getMillis(), logRecord.getLoggerName() + " " + logRecord.getSourceClassName() + "." + logRecord.getSourceMethodName() + " " + logRecord.getMessage())); } }
public static SessionLogs fromJSON(Map<String, Object> rawSessionLogs) { SessionLogs sessionLogs = new SessionLogs(); for (Map.Entry<String, Object> entry : rawSessionLogs.entrySet()) { String logType = entry.getKey(); Collection<?> rawLogEntries = (Collection<?>) entry.getValue(); List<LogEntry> logEntries = new ArrayList<>(); for (Object o : rawLogEntries) { @SuppressWarnings("unchecked") Map<String, Object> rawEntry = (Map<String, Object>) o; logEntries.add(new LogEntry( LogLevelMapping.toLevel(String.valueOf(rawEntry.get("level"))), ((Number) rawEntry.get("timestamp")).longValue(), String.valueOf(rawEntry.get("message")))); } sessionLogs.addLog(logType, new LogEntries(logEntries)); } return sessionLogs; }
@Test(expected = WebDriverException.class) public void shouldCheckForErrors() { //given when(webDriver.manage().logs().get(LogType.BROWSER)).thenReturn(new LogEntries(of(new LogEntry(Level.SEVERE, Instant.now().toEpochMilli(), "Fehler!")))); //when new LogErrorChecker().checkForErrors(webDriver, JobConfig.exampleConfig()); //then expect exception fail(); }
@Test public void shouldNotCheckForErrorsIfDisabled() { //given when(webDriver.manage().logs().get(LogType.BROWSER)).thenReturn(new LogEntries(of(new LogEntry(Level.SEVERE, Instant.now().toEpochMilli(), "Fehler!")))); JobConfig jobConfig = JobConfig.exampleConfigBuilder().withCheckForErrorsInLog(false).build(); //when new LogErrorChecker().checkForErrors(webDriver, jobConfig); //then expect no exception } }
public void call(ConsoleMessage message) { LogEntry entry = new LogEntry(OperaSeverity.get(message.getSeverity()).toLevel(), message.getTime(), message.getDescription()); logs.addEntry(message.getSource(), entry); }