1717
1818import org .apache .commons .lang3 .StringUtils ;
1919import org .apache .commons .lang3 .SystemUtils ;
20+ import org .apache .logging .log4j .LogManager ;
21+ import org .apache .logging .log4j .Logger ;
2022import org .labkey .serverapi .reader .Readers ;
2123import org .labkey .test .util .CachingSupplier ;
2224import org .labkey .test .util .CspLogUtil ;
2325import org .labkey .test .util .TestDataGenerator ;
24- import org .labkey .test .util .TestLogger ;
2526import org .labkey .test .util .Version ;
2627import org .openqa .selenium .Dimension ;
2728
4243import java .util .Objects ;
4344import java .util .Optional ;
4445import java .util .Properties ;
45- import java .util .Random ;
4646import java .util .stream .Collectors ;
4747import java .util .stream .Stream ;
4848
4949public abstract class TestProperties
5050{
51+ private static final Logger LOG = LogManager .getLogger (TestProperties .class );
52+
5153 static
5254 {
5355 final File propFile = new File (TestFileUtils .getTestRoot (), "test.properties" );
5456 final File propFileTemplate = new File (TestFileUtils .getTestRoot (), "test.properties.template" );
5557 if (!propFile .exists ())
5658 {
57- TestLogger . log ( String . format ( "'%s ' does not exist. Creating default from '%s '" , propFile .getName (), propFileTemplate .getName () ));
59+ LOG . info ( "'{} ' does not exist. Creating default from '{} '" , propFile .getName (), propFileTemplate .getName ());
5860 try (Stream <String > propStream = Files .lines (propFileTemplate .toPath ()))
5961 {
6062 final Iterator <String > iterator = propStream .filter (line -> !line .startsWith ("#!!" )).iterator ();
6163 Files .write (propFile .toPath (), (Iterable <String >) () -> iterator , StandardOpenOption .CREATE_NEW );
6264 }
6365 catch (IOException e )
6466 {
65- TestLogger .error (e .getMessage ());
67+ LOG .error (e .getMessage (), e );
6668 }
6769 }
6870 try (Reader propReader = Readers .getReader (propFile ))
6971 {
70- TestLogger . log ("Loading properties from " + propFile .getName ());
72+ LOG . info ("Loading properties from {}" , propFile .getName ());
7173 Properties properties = new Properties ();
7274 properties .load (propReader );
7375 properties .putAll (System .getProperties ());
7476 System .setProperties (properties );
7577 }
7678 catch (IOException ioe )
7779 {
78- TestLogger .error ("Failed to load " + propFile .getName () + " file. Running with hard-coded defaults" );
79- ioe .printStackTrace (System .err );
80+ LOG .error ("Failed to load {} file. Running with hard-coded defaults" , propFile .getName (), ioe );
8081 }
8182
8283 final List <String > gradleProperties = List .of ("labkeyVersion" );
@@ -85,7 +86,7 @@ public abstract class TestProperties
8586 {
8687 try (Reader propReader = Readers .getReader (serverPropFile ))
8788 {
88- TestLogger . log ("Loading properties from " + serverPropFile .getName ());
89+ LOG . info ("Loading properties from {}" , serverPropFile .getName ());
8990 Properties properties = new Properties ();
9091 properties .load (propReader );
9192 for (String key : gradleProperties )
@@ -98,8 +99,7 @@ public abstract class TestProperties
9899 }
99100 catch (IOException ioe )
100101 {
101- TestLogger .error ("Failed to load " + serverPropFile .getName () + " file." );
102- ioe .printStackTrace (System .err );
102+ LOG .error ("Failed to load {} file." , serverPropFile .getName (), ioe );
103103 }
104104 }
105105
@@ -298,9 +298,9 @@ public static boolean isTroubleshootingStacktracesEnabled()
298298 return getBooleanProperty ("webtest.troubleshooting.stacktraces" , false );
299299 }
300300
301- public static boolean isDebugLoggingEnabled ()
301+ public static String getTestLogLevel ()
302302 {
303- return getBooleanProperty ("webtest.logging.debug" , false );
303+ return System . getProperty ("webtest.log.level" );
304304 }
305305
306306 public static boolean isPrimaryUserAppAdmin ()
@@ -432,7 +432,7 @@ public static File getDumpDir()
432432 "Tried system properties failure.output.dir and java.io.tmpdir" );
433433 }
434434
435- TestLogger . log ("Using " + dumpDir + " to store test output" );
435+ LOG . info ("Using {} to store test output" , dumpDir );
436436 }
437437 return dumpDir ;
438438 }
@@ -475,7 +475,7 @@ public static int getIntegerProperty(String key, int def)
475475 }
476476 catch (NumberFormatException e )
477477 {
478- TestLogger .warn ("Invalid value for property %s : '%s'" . formatted ( key , prop ) , e );
478+ LOG .warn ("Invalid value for property {} : '{}'" , key , prop , e );
479479 }
480480 }
481481 return def ;
@@ -499,7 +499,7 @@ public static double getDoubleProperty(String key, double def)
499499 }
500500 catch (NumberFormatException e )
501501 {
502- TestLogger .warn ("Invalid value for property %s : '%s'" . formatted ( key , prop ) , e );
502+ LOG .warn ("Invalid value for property {} : '{}'" , key , prop , e );
503503 }
504504 }
505505 return def ;
0 commit comments