1
0
Fork 0

Add Logging Wrapper for Plugin

Add a wrapper to the logging commands to allow us to identify the plugin outputs
This commit is contained in:
Steven Cooney 2019-05-30 16:17:45 +01:00
parent 96a32ef190
commit b083db56ac
4 changed files with 42 additions and 5 deletions

View file

@ -9,6 +9,15 @@
<artifactId>phabricator-plugin-common</artifactId> <artifactId>phabricator-plugin-common</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>common-api</artifactId>
<version>${teamcity-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

View file

@ -0,0 +1,22 @@
package uk.xlab.teamcity.phabricator;
import jetbrains.buildServer.log.Loggers;
public final class PhabricatorPluginLogger {
public void serverInfo(String message) {
Loggers.SERVER.info(String.format("Phabricator Plugin: %s", message));
}
public void serverWarn(String message, Exception e) {
Loggers.SERVER.warn(message, e);
}
public void agentInfo(String message) {
Loggers.AGENT.info(String.format("Phabricator Plugin: %s", message));
}
public void agentWarn(String message, Exception e) {
Loggers.AGENT.warn(String.format("Phabricator Plugin: %s", message), e);
}
}

View file

@ -4,17 +4,22 @@ import java.util.Map;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import jetbrains.buildServer.log.Loggers;
import jetbrains.buildServer.serverSide.BuildFeature; import jetbrains.buildServer.serverSide.BuildFeature;
import jetbrains.buildServer.web.openapi.PluginDescriptor; import jetbrains.buildServer.web.openapi.PluginDescriptor;
public class PhabricatorPluginBuildFeature extends BuildFeature { public class PhabricatorPluginBuildFeature extends BuildFeature {
private final String myEditUrl; private final String myEditUrl;
private PhabricatorPluginLogger logger;
public PhabricatorPluginBuildFeature(@NotNull final PluginDescriptor pluginDescriptor) { public PhabricatorPluginBuildFeature(
@NotNull final PluginDescriptor pluginDescriptor,
@NotNull final PhabricatorPluginLogger logger
) {
myEditUrl = pluginDescriptor.getPluginResourcesPath("phabricatorBuildFeature.jsp"); myEditUrl = pluginDescriptor.getPluginResourcesPath("phabricatorBuildFeature.jsp");
this.logger = logger;
Loggers.SERVER.info("Phabricator build feature registered"); this.logger.serverInfo("Build feature registered");
} }
@Override @Override

View file

@ -4,5 +4,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-autowire="constructor"> default-autowire="constructor">
<bean class="uk.xlab.teamcity.phabricator.PhabricatorPluginBuildFeature"></bean> <bean class="uk.xlab.teamcity.phabricator.PhabricatorPluginBuildFeature" />
<bean class="uk.xlab.teamcity.phabricator.PhabricatorPluginLogger" />
</beans> </beans>