Package org.jboss.as.test.shared.util
Class LoggingUtil
java.lang.Object
org.jboss.as.test.shared.util.LoggingUtil
Utility class for logging repetitive tasks
- Author:
- tmiyar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longcountLines(Path logPath) static voiddumpTestLog(String logFileName) Helper method to dump the contents of a log to stdout.static voiddumpTestLog(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName) Helper method to dump the contents of a log to stdout.static PathgetInServerLogPath(String logFile) Will return the full log path for the given log file relative to the the jboss.server.log.dir.static PathgetLogPath(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 booleanhasLogMessage(String logFileName, String logMessage, Predicate<String>... filters) static booleanhasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, long offset, Predicate<String>... filters) static booleanhasLogMessage(org.jboss.as.arquillian.container.ManagementClient managementClient, String handlerName, String logMessage, Predicate<String>... filters)
-
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 handlerhandlerType- i.e. periodic-rotating-file-handler- Returns:
- Throws:
Exception
-
getInServerLogPath
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
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 handlerhandlerName- name of the handler that writes to the file- Throws:
Exception
-
countLines
- Throws:
Exception
-