com.atlassian.bamboo.build.logger
Class SimpleBuildLogger

java.lang.Object
  extended by com.atlassian.bamboo.build.logger.SimpleBuildLogger
All Implemented Interfaces:
BuildLogger

public class SimpleBuildLogger
extends Object
implements BuildLogger

The simple logger simply stores all the logs internally as a list... Useful for testing


Constructor Summary
SimpleBuildLogger()
           
 
Method Summary
 String addBuildLogEntry(LogEntry logEntry)
          Add a new build log entry.
 String addBuildLogEntry(String logString)
          Create a new build log entry from text to append to logs
 String addBuildLogHeader(String logString, boolean showBothBanner)
           
 String addErrorLogEntry(LogEntry logEntry)
          Add a new build error log entry.
 String addErrorLogEntry(String logString)
          Add a new build error log entry from text.
 void addErrorLogEntry(String logString, Throwable e)
          Adds an error log entry and each frame of the stack trace as a new error log entry
 void clearBuildLog()
          Reset the build log, ready for the next build
 void close()
           
 List<LogEntry> getBuildLog()
          Provide the latest build details (last 100 lines of logs).
 List<LogEntry> getErrorLog()
          Provide the latest error logs.
 LogInterceptorStack getInterceptorStack()
           
 List<LogEntry> getLastNLogEntries(int n)
          Provide the latest build details (last n lines of logs).
 List<String> getStringErrorLogs()
           
 List<String> getStringLogs()
           
 long getTimeOfLastLog()
          last time a log entry was added.
 void stopStreamingBuildLogs()
          Stop streaming any logs to the build logs file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBuildLogger

public SimpleBuildLogger()
Method Detail

getErrorLog

@NotNull
public List<LogEntry> getErrorLog()
Description copied from interface: BuildLogger
Provide the latest error logs. This is not persisted

Specified by:
getErrorLog in interface BuildLogger
Returns:
The list of LogEntrys.

getStringErrorLogs

public List<String> getStringErrorLogs()
Specified by:
getStringErrorLogs in interface BuildLogger

getBuildLog

@NotNull
public List<LogEntry> getBuildLog()
Description copied from interface: BuildLogger
Provide the latest build details (last 100 lines of logs). This is not persisted.

Specified by:
getBuildLog in interface BuildLogger
Returns:
The list of LogEntrys.

getStringLogs

public List<String> getStringLogs()

getLastNLogEntries

@NotNull
public List<LogEntry> getLastNLogEntries(int n)
Description copied from interface: BuildLogger
Provide the latest build details (last n lines of logs). This is not persisted.

Specified by:
getLastNLogEntries in interface BuildLogger
Returns:
The list of LogEntrys.

addBuildLogEntry

@NotNull
public String addBuildLogEntry(@NotNull
                                       LogEntry logEntry)
Description copied from interface: BuildLogger
Add a new build log entry. This will get appended to the end of the log.

Specified by:
addBuildLogEntry in interface BuildLogger
Parameters:
logEntry - The data being logged
Returns:
The line of text being logged. From LogEntry.getUnstyledLog().

addErrorLogEntry

@NotNull
public String addErrorLogEntry(@NotNull
                                       LogEntry logEntry)
Description copied from interface: BuildLogger
Add a new build error log entry. This will get appended to the end of the log and to the end of the errors.

Specified by:
addErrorLogEntry in interface BuildLogger
Parameters:
logEntry - The data being logged
Returns:
The line of text being logged. From LogEntry.getUnstyledLog().

addBuildLogEntry

public String addBuildLogEntry(@NotNull
                               String logString)
Description copied from interface: BuildLogger
Create a new build log entry from text to append to logs

Specified by:
addBuildLogEntry in interface BuildLogger
Parameters:
logString - text to create log entry from
Returns:
The line of text being logged. From LogEntry.getUnstyledLog().

addBuildLogHeader

public String addBuildLogHeader(String logString,
                                boolean showBothBanner)
Specified by:
addBuildLogHeader in interface BuildLogger

addErrorLogEntry

public String addErrorLogEntry(String logString)
Description copied from interface: BuildLogger
Add a new build error log entry from text. This will get appended to the end of the log and to the end of the errors.

Specified by:
addErrorLogEntry in interface BuildLogger
Parameters:
logString - The text to create log entry from
Returns:
The line of text being logged. From LogEntry.getUnstyledLog().

addErrorLogEntry

public void addErrorLogEntry(String logString,
                             @Nullable
                             Throwable e)
Description copied from interface: BuildLogger
Adds an error log entry and each frame of the stack trace as a new error log entry

Specified by:
addErrorLogEntry in interface BuildLogger

clearBuildLog

public void clearBuildLog()
Description copied from interface: BuildLogger
Reset the build log, ready for the next build

Specified by:
clearBuildLog in interface BuildLogger

stopStreamingBuildLogs

public void stopStreamingBuildLogs()
Description copied from interface: BuildLogger
Stop streaming any logs to the build logs file

Specified by:
stopStreamingBuildLogs in interface BuildLogger

getTimeOfLastLog

public long getTimeOfLastLog()
Description copied from interface: BuildLogger
last time a log entry was added. If no logs, returns 0

Specified by:
getTimeOfLastLog in interface BuildLogger
Returns:

getInterceptorStack

@NotNull
public LogInterceptorStack getInterceptorStack()
Specified by:
getInterceptorStack in interface BuildLogger
Returns:
stack of log interceptors attached to this build logger

close

public void close()
Specified by:
close in interface BuildLogger


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.