Class LoggingUtil

java.lang.Object
org.jboss.as.test.shared.util.LoggingUtil

public class LoggingUtil extends Object
Utility class for logging repetitive tasks
Author:
tmiyar
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    countLines(Path logPath)
     
    static void
    dumpTestLog(String logFileName)
    Helper method to dump the contents of a log to stdout.
    static void
    dumpTestLog(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName)
    Helper method to dump the contents of a log to stdout.
    static Path
    Will return the full log path for the given log file relative to the the jboss.server.log.dir.
    static Path
    getLogPath(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerType, String name)
    Will return the full log path for the handler in the name parameter, to be used when using @RunAsClient annotation Depending on how you run it you might need some permissions: new PropertyPermission("node0", "read"), new RemotingPermission("connect"), new SocketPermission(Utils.getDefaultHost(true), "accept,connect,listen,resolve"), new RuntimePermission("getClassLoader")
    static boolean
    hasLogMessage(String logFileName, String logMessage, Predicate<String>... filters)
     
    static boolean
    hasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, long offset, Predicate<String>... filters)
     
    static boolean
    hasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, Predicate<String>... filters)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LoggingUtil

      public LoggingUtil()
  • Method Details

    • getLogPath

      public static Path getLogPath(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerType, String name) throws Exception
      Will return the full log path for the handler in the name parameter, to be used when using @RunAsClient annotation Depending on how you run it you might need some permissions: new PropertyPermission("node0", "read"), new RemotingPermission("connect"), new SocketPermission(Utils.getDefaultHost(true), "accept,connect,listen,resolve"), new RuntimePermission("getClassLoader")
      Parameters:
      managementClient -
      name - of handler
      handlerType - i.e. periodic-rotating-file-handler
      Returns:
      Throws:
      Exception
    • getInServerLogPath

      public static Path getInServerLogPath(String logFile)
      Will return the full log path for the given log file relative to the the jboss.server.log.dir. Meant for use by test code that runs in the server VM. Tests that use this should add the following permission to allow the call to succeed in a testsuite run with the security manager enabled: new PropertyPermission("jboss.server.log.dir", "read")
      Parameters:
      logFile - name of the log file, relative to the server log directory
      Returns:
      the path
    • hasLogMessage

      @SafeVarargs public static boolean hasLogMessage(String logFileName, String logMessage, Predicate<String>... filters) throws Exception
      Throws:
      Exception
    • hasLogMessage

      @SafeVarargs public static boolean hasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, Predicate<String>... filters) throws Exception
      Throws:
      Exception
    • hasLogMessage

      @SafeVarargs public static boolean hasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, long offset, Predicate<String>... filters) throws Exception
      Throws:
      Exception
    • dumpTestLog

      public static void dumpTestLog(String logFileName) throws IOException
      Helper method to dump the contents of a log to stdout.
      Parameters:
      logFileName - the name of the log file
      Throws:
      IOException
    • dumpTestLog

      public static void dumpTestLog(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName) throws Exception
      Helper method to dump the contents of a log to stdout.
      Parameters:
      managementClient - client to use the name of the log file used by a handler
      handlerName - name of the handler that writes to the file
      Throws:
      Exception
    • countLines

      public static long countLines(Path logPath) throws Exception
      Throws:
      Exception