-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jenkinsci/referenceImpl
External Logging API Implementation. v1
- Loading branch information
Showing
40 changed files
with
1,862 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
target | ||
|
||
# mvn hpi:run | ||
work | ||
|
||
# IntelliJ IDEA project files | ||
*.iml | ||
*.iws | ||
*.ipr | ||
.idea | ||
|
||
# Eclipse project files | ||
.settings | ||
.classpath | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd"> | ||
<extension> | ||
<groupId>io.jenkins.tools.incrementals</groupId> | ||
<artifactId>git-changelist-maven-extension</artifactId> | ||
<version>1.0-beta-3</version> | ||
</extension> | ||
</extensions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-Pconsume-incrementals | ||
-Pmight-produce-incrementals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
buildPlugin(platforms: ['linux']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>3.18</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<groupId>io.jenkins.plugins.external-logging</groupId> | ||
<artifactId>external-logging-api</artifactId> | ||
<name>External Logging API plugin</name> | ||
<description>The plugin provides API to simplify external logging implementations for Jenkins</description> | ||
<url>https://wiki.jenkins.io/display/JENKINS/External+Logging+API+Plugin</url> | ||
<version>${revision}${changelist}</version> | ||
<packaging>hpi</packaging> | ||
|
||
<properties> | ||
<revision>1.0-alpha-1</revision> | ||
<changelist>-SNAPSHOT</changelist> | ||
<jenkins.version>2.135-rc15088.42aa6febbbed</jenkins.version> | ||
<java.level>8</java.level> | ||
<useBeta>true</useBeta> | ||
</properties> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>https://opensource.org/licenses/MIT</url> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection> | ||
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection> | ||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
<tag>${scmTag}</tag> | ||
</scm> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>unique-id</artifactId> | ||
<version>2.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>mask-passwords</artifactId> | ||
<version>2.12.0</version> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-job</artifactId> | ||
<version>2.22-rc311.5616213fbed0</version> <!-- TODO https://github.com/jenkinsci/workflow-job-plugin/pull/27 --> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-support</artifactId> | ||
<version>2.19-rc265.3e5e4aeecfff</version> <!-- TODO https://github.com/jenkinsci/workflow-support-plugin/pull/15 --> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-api</artifactId> | ||
<version>2.29-rc219.239019e84015</version> <!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/17 --> | ||
</dependency> | ||
|
||
<!-- For testing of Log wrapping in Pipeline --> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-durable-task-step</artifactId> | ||
<version>2.20-rc333.74dc7c303e6d</version> <!-- TODO https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/21 --> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-cps</artifactId> | ||
<version>2.19</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-basic-steps</artifactId> | ||
<version>2.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
<artifactId>workflow-step-api</artifactId> | ||
<version>2.15</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>scm-api</artifactId> | ||
<version>2.2.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>script-security</artifactId> | ||
<version>1.39</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>credentials-binding</artifactId> | ||
<version>1.15</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
</project> |
54 changes: 54 additions & 0 deletions
54
src/main/java/io/jenkins/plugins/extlogging/api/Event.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.jenkins.plugins.extlogging.api; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Stores events which can be sent over the channel. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public class Event { | ||
|
||
final String message; | ||
final long timestamp; | ||
final long id; | ||
|
||
Map<String, Serializable> data = new HashMap<>(); | ||
|
||
public Event(long id, String message, long timestamp) { | ||
this.id = id; | ||
this.message = message; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public Map<String, Serializable> getData() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("[%d] - %s", timestamp, message); | ||
} | ||
|
||
public void setData(Map<String, Serializable> data) { | ||
this.data = data; | ||
} | ||
|
||
public String toStringWithData() { | ||
return String.format("[%d] - %s: %s", timestamp, message, data); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/io/jenkins/plugins/extlogging/api/ExternalLogBrowser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.jenkins.plugins.extlogging.api; | ||
|
||
import jenkins.model.logging.LogBrowser; | ||
import jenkins.model.logging.Loggable; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Base abstract class for External Log Browsers. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public abstract class ExternalLogBrowser extends LogBrowser { | ||
|
||
public ExternalLogBrowser(@Nonnull Loggable loggable) { | ||
super(loggable); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/io/jenkins/plugins/extlogging/api/ExternalLogBrowserFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.jenkins.plugins.extlogging.api; | ||
|
||
import hudson.ExtensionPoint; | ||
import hudson.model.Describable; | ||
import hudson.model.Descriptor; | ||
import jenkins.model.Jenkins; | ||
import jenkins.model.logging.LogBrowser; | ||
import jenkins.model.logging.Loggable; | ||
|
||
import javax.annotation.CheckForNull; | ||
|
||
/** | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public abstract class ExternalLogBrowserFactory | ||
implements Describable<ExternalLogBrowserFactory>, ExtensionPoint { | ||
|
||
@CheckForNull | ||
public abstract LogBrowser create(Loggable loggable); | ||
|
||
@Override | ||
public Descriptor<ExternalLogBrowserFactory> getDescriptor() { | ||
return Jenkins.get().getDescriptor(getClass()); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/io/jenkins/plugins/extlogging/api/ExternalLogBrowserFactoryDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.jenkins.plugins.extlogging.api; | ||
|
||
import hudson.model.Descriptor; | ||
|
||
/** | ||
* Descriptor for {@link ExternalLogBrowserFactory} | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public class ExternalLogBrowserFactoryDescriptor | ||
extends Descriptor<ExternalLogBrowserFactory> { | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/io/jenkins/plugins/extlogging/api/ExternalLoggingEventWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.jenkins.plugins.extlogging.api; | ||
|
||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import java.io.Writer; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* Implements logging of events | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public abstract class ExternalLoggingEventWriter extends Writer implements Serializable { | ||
|
||
Map<String, Serializable> metadata = new HashMap<>(); | ||
AtomicLong messageCounter = new AtomicLong(); | ||
|
||
public abstract void writeEvent(Event event) throws IOException; | ||
|
||
public void writeMessage(String message) throws IOException { | ||
Event event = new Event(messageCounter.getAndIncrement(), message, System.currentTimeMillis()); | ||
event.setData(metadata); // We do not copy the entry to save performance, custom implementations may need better logic | ||
writeEvent(event); | ||
} | ||
|
||
public void addMetadataEntry(String key, Serializable value) { | ||
metadata.put(key, value); | ||
} | ||
|
||
@Override | ||
public void write(char[] cbuf, int off, int len) throws IOException { | ||
String message = new String(cbuf, off, len); | ||
writeMessage(message); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
// noop | ||
} | ||
|
||
@Override | ||
public void flush() throws IOException { | ||
// noop | ||
} | ||
} |
Oops, something went wrong.