public class ScriptLogger extends Object implements OutputObject
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Class and Description |
---|---|
static class |
ScriptLogger.CustomLogManager
Custom
LogManager supporting calls during the process shutdown. |
static class |
ScriptLogger.ExitType
Indicates why a script terminated, for example reaching of the code end,
call of the Exit command, stopping by the user or an app/process crash.
|
Modifier and Type | Field and Description |
---|---|
static MessageFormat |
FORMAT |
static String |
LOG_FILE_NAME |
static String |
PROPERTY_CHANGE_LOG_CLOSED |
static String |
PROPERTY_CHANGE_LOG_CLOSING |
static String |
PROPERTY_CHANGE_NEW_LOG |
static String |
TIME_STAMP_FORMAT |
static String |
VAR_SEVERE_COUNT |
static String |
VAR_WARNING_COUNT |
TYPE_ERROR, TYPE_LOG, TYPE_SCREENSHOT, TYPE_STATUS, TYPE_UNKNOWN, TYPE_WARNING
Constructor and Description |
---|
ScriptLogger(ScriptingContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
addHtmlLogListener(PropertyChangeListener l) |
boolean |
canLog(Level level) |
void |
close() |
String |
getCode()
Get code of the output object.
|
ScriptLocation |
getCurrentPosition() |
ScriptLocation |
getCurrentPosition(Stack<ScriptLocation> position) |
Date |
getDate()
Get date and time of when the output object was created.
|
String |
getDescription()
Get the output object description.
|
ScriptLocation |
getExitPoint() |
ScriptLocation[] |
getExitStack() |
ScriptLogger.ExitType |
getExitType() |
String |
getLastLog()
Get the last log entry.
|
Stack<ScriptLocation> |
getStackCopy()
Get a copy of the current stack.
|
StringBuilder |
getStackTrace() |
StringBuilder |
getStackTrace(boolean useHead,
boolean useHTML) |
StringBuilder |
getStackTrace(Stack<ScriptLocation> position,
boolean useHead,
boolean useHTML) |
ScriptLocation |
getStartPoint() |
static List<Level> |
getSupportedLogLevels() |
int |
getType()
Get the output object type.
|
boolean |
isClosed() |
void |
leavingFile(ScriptingContext ctx,
Object scriptFile)
Method to indicate that a file based test script has been completed and
all top stack items related to that file should be popped.
|
void |
log(Level level,
String message) |
void |
logConfig(String message) |
void |
logFine(String message) |
void |
logFiner(String message) |
void |
logFinest(String message) |
void |
logInfo(String message) |
void |
logRaw(Level level,
String message) |
void |
logRaw(Level level,
String message,
Long time) |
void |
logRawHTML(String html) |
void |
logSevere(String message) |
void |
logSevere(String message,
boolean closeLog)
Log a severe error and optionally close the log stream if the error
causes the script to terminate.
|
void |
logWarning(String message) |
void |
popCurrentPosition(ScriptingContext ctx) |
void |
printStackTrace() |
void |
pushCurrentPosition(ScriptingContext ctx) |
void |
recordExitStack() |
void |
removeHtmlLogListener(PropertyChangeListener l) |
void |
setBulkUpdate(boolean bulk) |
void |
setCurrentPosition(ScriptingContext ctx,
Object scriptFile,
int lineIndex,
String line) |
void |
setExitType(ScriptLogger.ExitType type,
String details) |
Map<String,Object> |
toMap()
Return a map of valid properties of this output object.
|
String |
toString() |
public static String PROPERTY_CHANGE_NEW_LOG
public static String PROPERTY_CHANGE_LOG_CLOSING
public static String PROPERTY_CHANGE_LOG_CLOSED
public static String LOG_FILE_NAME
public static final String TIME_STAMP_FORMAT
public static final MessageFormat FORMAT
public static final String VAR_WARNING_COUNT
public static final String VAR_SEVERE_COUNT
public ScriptLogger(ScriptingContext ctx)
public String getLastLog()
public void addHtmlLogListener(PropertyChangeListener l)
public void removeHtmlLogListener(PropertyChangeListener l)
public int getType()
OutputObject
getType
in interface OutputObject
public String getCode()
OutputObject
getCode
in interface OutputObject
public String getDescription()
OutputObject
getDescription
in interface OutputObject
public Date getDate()
OutputObject
getDate
in interface OutputObject
public Map<String,Object> toMap()
OutputObject
toMap
in interface OutputObject
public ScriptLocation getCurrentPosition()
public ScriptLocation getCurrentPosition(Stack<ScriptLocation> position)
public void setCurrentPosition(ScriptingContext ctx, Object scriptFile, int lineIndex, String line)
public void leavingFile(ScriptingContext ctx, Object scriptFile)
ctx
- the execution context.scriptFile
- the script file.public void pushCurrentPosition(ScriptingContext ctx)
public void popCurrentPosition(ScriptingContext ctx)
public void setExitType(ScriptLogger.ExitType type, String details)
public ScriptLogger.ExitType getExitType()
public boolean canLog(Level level)
public void setBulkUpdate(boolean bulk)
public void logRawHTML(String html)
public void logSevere(String message, boolean closeLog)
message
- the error message.closeLog
- if the value is true the log stream is closed and the
error message gets logged as a final log. This avoids duplication of the
error log when a sequence of logSevere(java.lang.String)
and
close()
.public void logWarning(String message)
public void logSevere(String message)
public void logFine(String message)
public void logFiner(String message)
public void logFinest(String message)
public void logConfig(String message)
public void logInfo(String message)
public StringBuilder getStackTrace()
public StringBuilder getStackTrace(boolean useHead, boolean useHTML)
public StringBuilder getStackTrace(Stack<ScriptLocation> position, boolean useHead, boolean useHTML)
public void printStackTrace()
public ScriptLocation getExitPoint()
public ScriptLocation getStartPoint()
public ScriptLocation[] getExitStack()
public boolean isClosed()
public void recordExitStack()
public void close()
public Stack<ScriptLocation> getStackCopy()