Exemplo n.º 1
0
 public static List<String> convert(List<LogEntry> entries) {
   List<String> strings = new ArrayList<String>();
   for (LogEntry entry : entries) {
     strings.add(entry.toString());
   }
   return strings;
 }
Exemplo n.º 2
0
 private String getMessage(LogEntry entry) {
   String color = "black";
   switch (entry.m_Level) {
     case ERROR:
       color = "red";
       break;
     case WARN:
       color = "yellow";
     case INFO:
       break;
     case DEBUG:
       color = "gray";
       break;
     case UNKNOWN:
       break;
     default:
       break;
   }
   String ret = entry.toString(logType);
   if (ret == null) {
     return "";
   }
   return "<font color=\""
       + color
       + "\">"
       + (ret.replace("<", "&lt;")
           .replace(">", "&gt;")
           .trim()
           .replace("\r\n", "\n")
           .replace("\n", "<br/>"))
       + "</font><br/>";
 }
Exemplo n.º 3
0
  @NeedsFreshDriver
  @Test
  public void clientLogShouldBeEnabledByDefault() {
    // Do one action to have *something* in the client logs.
    driver.get(pages.formPage);
    Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();
    assertTrue("Client logs should be enabled by default", logTypes.contains(LogType.CLIENT));
    boolean foundExecutingStatement = false;
    boolean foundExecutedStatement = false;
    for (LogEntry logEntry : driver.manage().logs().get(LogType.CLIENT)) {
      foundExecutingStatement |= logEntry.toString().contains("Executing: ");
      foundExecutedStatement |= logEntry.toString().contains("Executed: ");
    }

    assertTrue(foundExecutingStatement);
    assertTrue(foundExecutedStatement);
  }
Exemplo n.º 4
0
  public void save(String msg) {

    if (NTClient.ENVIRONMENT != NTClient.PHONE_PROD_ENV) System.out.println(msg);
    LogEntry entry = new LogEntry(msg);
    if (lineBuffer != null) lineBuffer.offer(entry);
    if (isFileModeActive()) {
      synchronized (logFileWriter) {
        try {
          logFileWriter.write(entry.toString() + "\n");
        } catch (Exception e) {
          disableFileMode();
        }
      }
    }
    if (ntWebAPI != null) {
      try {
        ntWebAPI.postLog(entry.toString() + "\n");
      } catch (Exception e) {
        ntWebAPI = null; // disable web mode
      }
    }
  }
Exemplo n.º 5
0
 public void run() {
   LogEntry entry;
   try {
     while ((entry = logQueue.take()) != null) {
       if (listeners.isEmpty()) {
         (entry.m_Level == LogLevel.ERROR ? System.err : System.out)
             .println(entry.toString(ELogType.DEBUG));
       } else {
         List<ILogListener> tempListeners = new ArrayList<ILogListener>();
         tempListeners.addAll(listeners);
         for (ILogListener listener : tempListeners) {
           listener.onLogEvent(entry);
         }
       }
     }
   } catch (InterruptedException ignored) {
   }
 }