aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-28 17:24:51 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-28 17:24:51 +0100
commit695c875725b30a1a348f9c8a84e2bdd5ec1f3a82 (patch)
treee5e5049bb88621c3c80938fbda570404d3dc73fc /src/main/java/io
parent54ec271b75dad82da9bd4ee2975a22490d66d6dc (diff)
downloadesper-testing-695c875725b30a1a348f9c8a84e2bdd5ec1f3a82.tar.gz
esper-testing-695c875725b30a1a348f9c8a84e2bdd5ec1f3a82.tar.bz2
esper-testing-695c875725b30a1a348f9c8a84e2bdd5ec1f3a82.tar.xz
esper-testing-695c875725b30a1a348f9c8a84e2bdd5ec1f3a82.zip
o Sending logs to to disk.
Diffstat (limited to 'src/main/java/io')
-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
10 files changed, 25 insertions, 12 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);
}