aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/trygvis/esper/testing/Config.java19
-rw-r--r--src/main/java/io/trygvis/esper/testing/core/badge/UnbreakablePoller.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/esper/Test1.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/esper/Test2.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/esper/Test3.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/web/WebConfig.java2
-rw-r--r--src/main/resources/logback.xml19
-rw-r--r--src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java2
-rw-r--r--src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java2
-rw-r--r--src/test/java/io/trygvis/esper/testing/web/WebRunner.java5
14 files changed, 47 insertions, 18 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java
index 5beb9bb..5ff579f 100644
--- a/src/main/java/io/trygvis/esper/testing/Config.java
+++ b/src/main/java/io/trygvis/esper/testing/Config.java
@@ -11,6 +11,8 @@ import java.util.*;
import java.util.concurrent.atomic.*;
import static fj.data.Option.*;
+import static java.lang.System.err;
+import static java.lang.System.exit;
import static org.apache.commons.lang.StringUtils.*;
public class Config {
@@ -60,10 +62,10 @@ public class Config {
this.databasePassword = databasePassword;
}
- public static Config loadFromDisk() throws IOException {
+ public static Config loadFromDisk(String appName) throws IOException {
initSystemProperties();
- initLogging();
+ initLogging(appName);
Properties properties = new Properties();
try (FileInputStream inputStream = new FileInputStream("etc/config.properties")) {
@@ -84,7 +86,18 @@ public class Config {
System.setProperty("jsse.enableSNIExtension", "false");
}
- private static void initLogging() {
+ private static void initLogging(String appName) {
+ System.setProperty("logging.app", appName);
+
+ File logs = new File("logs");
+
+ if(!logs.isDirectory()) {
+ if(!logs.mkdirs()) {
+ err.println("Could not create logs directory: " + logs.getAbsolutePath());
+ exit(1);
+ }
+ }
+
LoggerFactory.getILoggerFactory();
// LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
// StatusPrinter.print(lc);
diff --git a/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakablePoller.java b/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakablePoller.java
index 1d0a947..05d4976 100644
--- a/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakablePoller.java
+++ b/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakablePoller.java
@@ -28,7 +28,7 @@ public class UnbreakablePoller implements TablePoller.NewRowCallback<BuildDto> {
SqlF<ResultSet, BuildDto> f = BuildDao.build;
TablePoller.NewRowCallback<BuildDto> callback = new UnbreakablePoller();
- Config config = loadFromDisk();
+ Config config = loadFromDisk("unbreakable-poller");
BoneCPDataSource dataSource = config.createBoneCp();
diff --git a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
index 9f22166..bfcd013 100644
--- a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
+++ b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
@@ -25,7 +25,7 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
SqlF<ResultSet, JenkinsBuildDto> f = JenkinsDao.jenkinsBuild;
TablePoller.NewRowCallback<JenkinsBuildDto> callback = new JenkinsBuildPoller();
- Config config = loadFromDisk();
+ Config config = loadFromDisk("jenkins-build-poller");
BoneCPDataSource dataSource = config.createBoneCp();
diff --git a/src/main/java/io/trygvis/esper/testing/esper/Test1.java b/src/main/java/io/trygvis/esper/testing/esper/Test1.java
index 43f857b..c4e8c90 100644
--- a/src/main/java/io/trygvis/esper/testing/esper/Test1.java
+++ b/src/main/java/io/trygvis/esper/testing/esper/Test1.java
@@ -16,7 +16,7 @@ public class Test1 {
EPRuntime runtime;
public static void main(String[] args) throws Exception {
- Config.loadFromDisk();
+ Config.loadFromDisk("test-1");
new Test1().work();
}
diff --git a/src/main/java/io/trygvis/esper/testing/esper/Test2.java b/src/main/java/io/trygvis/esper/testing/esper/Test2.java
index ecd276a..6e0db3b 100644
--- a/src/main/java/io/trygvis/esper/testing/esper/Test2.java
+++ b/src/main/java/io/trygvis/esper/testing/esper/Test2.java
@@ -17,7 +17,7 @@ public class Test2 {
}
public static void main(String[] args) throws Exception {
- config = Config.loadFromDisk();
+ config = Config.loadFromDisk("test-2");
Configuration c = new Configuration();
diff --git a/src/main/java/io/trygvis/esper/testing/esper/Test3.java b/src/main/java/io/trygvis/esper/testing/esper/Test3.java
index 1c007b9..a1599ca 100644
--- a/src/main/java/io/trygvis/esper/testing/esper/Test3.java
+++ b/src/main/java/io/trygvis/esper/testing/esper/Test3.java
@@ -16,7 +16,7 @@ public class Test3 {
EPRuntime runtime;
public static void main(String[] args) throws Exception {
- Config.loadFromDisk();
+ Config.loadFromDisk("test-3");
new Test3().work();
}
diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
index 9fe809c..67b6d17 100644
--- a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
+++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousProjectDiscovery.java
@@ -25,7 +25,7 @@ public class GitoriousProjectDiscovery {
private final GitoriousClient gitoriousClient;
public static void main(String[] args) throws Exception {
- Config config = Config.loadFromDisk();
+ Config config = Config.loadFromDisk("gitorious-project-discovery");
new GitoriousProjectDiscovery(config);
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
index 3a688eb..fb72a99 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
@@ -17,7 +17,7 @@ import static java.lang.Thread.*;
public class JenkinsImporter {
public static void main(String[] args) throws Exception {
- final Config config = Config.loadFromDisk();
+ final Config config = Config.loadFromDisk("jenkins-importer");
final BoneCPDataSource boneCp = config.createBoneCp();
HTTPCache httpCache = HttpClient.createHttpCache(config);
Abdera abdera = config.createAbdera();
diff --git a/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java b/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java
index 024cde2..8beec37 100644
--- a/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java
+++ b/src/main/java/io/trygvis/esper/testing/nexus/NexusImporter.java
@@ -17,7 +17,7 @@ import java.util.concurrent.atomic.*;
public class NexusImporter {
public static void main(String[] args) throws Exception {
- final Config config = Config.loadFromDisk();
+ final Config config = Config.loadFromDisk("nexus-importer");
final HTTPCache http = HttpClient.createHttpCache(config);
final XmlParser xmlParser = new XmlParser();
final BoneCPDataSource boneCp = config.createBoneCp();
diff --git a/src/main/java/io/trygvis/esper/testing/web/WebConfig.java b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java
index 02fb4ff..d2cfc41 100644
--- a/src/main/java/io/trygvis/esper/testing/web/WebConfig.java
+++ b/src/main/java/io/trygvis/esper/testing/web/WebConfig.java
@@ -9,7 +9,7 @@ public class WebConfig {
static {
try {
- config = Config.loadFromDisk();
+ config = Config.loadFromDisk("web");
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index 1f6becf..c815e52 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,6 +1,20 @@
<configuration debug="false">
+ <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>logs/${logging.app}.log</file>
+ <append>true</append>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>logs/${logging.app}-%d.log</fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %-30logger{1} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ </filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %-30logger{1} - %msg%n</pattern>
</encoder>
@@ -14,9 +28,10 @@
<logger name="io.trygvis.esper.testing.util.HttpClient" level="INFO"/>
- <logger name="org.apache.shiro" level="DEBGU"/>
+ <logger name="org.apache.shiro" level="DEBUG"/>
- <root level="INFO">
+ <root>
<appender-ref ref="STDOUT"/>
+ <appender-ref ref="FILE"/>
</root>
</configuration>
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
index a8f8ce7..13a78d7 100644
--- a/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
@@ -22,7 +22,7 @@ import static io.trygvis.esper.testing.jenkins.JenkinsClient.apiXml;
public class CreateMissingMavenModuleJobsApp {
public static void main(String[] args) throws Exception {
- final Config config = Config.loadFromDisk();
+ final Config config = Config.loadFromDisk("create-missing-maven-module");
final BoneCPDataSource boneCp = config.createBoneCp();
HTTPCache httpCache = HttpClient.createHttpCache(config);
Abdera abdera = config.createAbdera();
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java b/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java
index ffd3212..f272feb 100644
--- a/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java
@@ -19,7 +19,7 @@ import static io.trygvis.esper.testing.jenkins.JenkinsClient.apiXml;
public class SetJobTypeApp {
public static void main(String[] args) throws Exception {
- final Config config = Config.loadFromDisk();
+ final Config config = Config.loadFromDisk("set-job-type");
final BoneCPDataSource boneCp = config.createBoneCp();
HTTPCache httpCache = HttpClient.createHttpCache(config);
Abdera abdera = config.createAbdera();
diff --git a/src/test/java/io/trygvis/esper/testing/web/WebRunner.java b/src/test/java/io/trygvis/esper/testing/web/WebRunner.java
index 2e73b9f..60644de 100644
--- a/src/test/java/io/trygvis/esper/testing/web/WebRunner.java
+++ b/src/test/java/io/trygvis/esper/testing/web/WebRunner.java
@@ -1,6 +1,7 @@
package io.trygvis.esper.testing.web;
import io.trygvis.appsh.booter.jetty.*;
+import io.trygvis.esper.testing.*;
import org.slf4j.bridge.*;
import java.io.*;
@@ -8,8 +9,8 @@ import java.io.*;
public class WebRunner {
public static void main(String[] args) throws Exception {
- SLF4JBridgeHandler.removeHandlersForRootLogger();
- SLF4JBridgeHandler.install();
+ // Ensures that the system has been initialized
+ @SuppressWarnings("UnusedDeclaration") Config config = WebConfig.config;
JettyWebServer server = new JettyWebServer();
server.setHttpPort(1337);