@NotThreadSafe public class SyncLogger extends Object
synchronizer implementations
.
It prepends the specified messages with the following information:
SynchronizerDescriptor.getLabel()
,synchronizer instance
.Name of the user under which the synchronization is run is not provided, as it is automatically inserted into the log message by JIRA.
There is a bunch of helper methods to pretty-print the user under which the synchronizer runs (username()
),
produce warnings about typical StructureExceptions
that may be encountered by synchronizers (warnStructureException(StructureException)
),
and select messages based on the synchronization mode (selectBySyncMode(Object, Object, Object)
).
All logging methods that take Object...
vararg parameter delimit its contents putting a single space before the parameter. If the parameter is a character or a single-character String
that is a punctuation mark, the space is not inserted before the parameter. If the parameter is an Object[]
, its contents are added to the output as if they belonged to the original Object...
parameter.
Example:
SyncLogger log = ... ; log.warn("cannot run because of", isKaboozle() ? "kaboozle" : new Object[]{"grumbles with error", getError()}, ':', getCause())
will produce the following log message:
<synchronizer label> autosync #239 for structure 'Unresolved in 2.0' (#156) cannot run because of grumbles with error FATAL: something went wrong
Methods that end with exceptionIfDebug
attempt to log exception stack trace if log level is DEBUG or lower and print only exception message if log level is higher.
StructureSynchronizer
Constructor and Description |
---|
SyncLogger(Logger logger,
SyncInstance sync,
StructureManager structureManager,
RowManager rowManager,
boolean auto) |
Modifier and Type | Method and Description |
---|---|
StringBuilder |
appendForest(Forest forest,
StringBuilder sb) |
StringBuilder |
appendIssue(Long issueId,
StringBuilder sb)
Adds debug information about an issue by ID.
|
StringBuilder |
appendItem(ItemIdentity itemId,
StringBuilder sb) |
StringBuilder |
appendItem(long rowId,
StringBuilder sb) |
StringBuilder |
appendItemForest(ItemForest itemForest,
StringBuilder sb) |
StringBuilder |
appendRows(LongIterable rowIds,
StringBuilder sb) |
String |
createLogMessage(Object... msgs) |
void |
debug(Object... msgs) |
void |
debugException(Throwable ex,
Object... msgs) |
String |
defaultPrefix() |
void |
error(Object... msgs) |
void |
errorException(Throwable e,
Object... msgs) |
String |
forest(Forest forest) |
static SyncLogger |
get()
Retrieves SyncLogger from the thread-local storage.
|
Logger |
getLogger() |
String |
getPrefix() |
void |
info(Object... msgs) |
void |
infoException(Throwable e,
Object... msgs) |
boolean |
isAutoSync() |
static boolean |
isDebug() |
boolean |
isDebugEnabled() |
static boolean |
isInfo() |
boolean |
isInfoEnabled() |
boolean |
isOneTimeSync() |
String |
issue(Issue issue) |
String |
issue(Long issueId)
Retrieves debug information about an issue by ID.
|
String |
issues(Iterable<? extends Issue> issues) |
String |
issues(LongIterable issues) |
String |
itemForest(ItemForest itemForest) |
void |
popPrefix() |
void |
pushPrefix(String prefixToAppend) |
String |
row(long rowId) |
String |
rows(LongIterable rowIds) |
Object |
selectBySyncMode(Object ifAuto,
Object ifResync,
Object ifOneTime) |
static void |
set(SyncLogger syncLog)
This is internal method that is used by the synchronization subsystem.
|
void |
setLogger(Logger logger) |
void |
setPrefix(String prefix) |
String |
structure(long structureId) |
String |
username() |
void |
warn(Object... msgs) |
void |
warnException(Throwable ex,
Object... msgs) |
void |
warnExceptionIfDebug(Throwable ex,
Object... msgs) |
String |
warnStructureException(StructureException e)
Contains standard error descriptions for common StructureExceptions
|
public SyncLogger(Logger logger, @Nullable SyncInstance sync, StructureManager structureManager, RowManager rowManager, boolean auto)
@NotNull public static SyncLogger get()
Retrieves SyncLogger from the thread-local storage. Must only be called during synchronization; if called
at any other time, throws an UnsupportedOperationException
.
The returned SyncLogger delegates to Logger
for the current StructureSynchronizer
class.
@Internal public static void set(@Nullable SyncLogger syncLog)
UnsupportedOperationException
being thrown.public static boolean isInfo()
public static boolean isDebug()
@NotNull public String getPrefix()
public void setPrefix(@NotNull String prefix)
public void pushPrefix(@NotNull String prefixToAppend)
public void popPrefix()
public Logger getLogger()
public void setLogger(Logger logger)
public boolean isOneTimeSync()
public boolean isAutoSync()
public void info(Object... msgs)
public void debug(Object... msgs)
public void warn(Object... msgs)
public void error(Object... msgs)
public boolean isInfoEnabled()
public boolean isDebugEnabled()
public final String defaultPrefix()
@NotNull public String username()
@NotNull public String issue(Long issueId)
public StringBuilder appendIssue(Long issueId, StringBuilder sb)
@NotNull public String issue(@Nullable Issue issue)
public String issues(@Nullable LongIterable issues)
@NotNull public String structure(long structureId)
public StringBuilder appendForest(Forest forest, StringBuilder sb)
public StringBuilder appendItemForest(ItemForest itemForest, StringBuilder sb)
public String itemForest(ItemForest itemForest)
public StringBuilder appendRows(LongIterable rowIds, StringBuilder sb)
public StringBuilder appendItem(long rowId, StringBuilder sb)
public StringBuilder appendItem(ItemIdentity itemId, StringBuilder sb)
public String row(long rowId)
public String rows(LongIterable rowIds)
@Nullable public String warnStructureException(StructureException e)
Copyright © 2024 Tempo Software. All Rights Reserved.