Package org.goplanit.utils.misc
Class LoggingUtils
- java.lang.Object
-
- org.goplanit.utils.misc.LoggingUtils
-
public class LoggingUtils extends Object
some utilities for consistent logging message creation in PLANit- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description LoggingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
demandsPrefix(long demandsId)
Create a prefix for the logger so that all logging items specific to a particular demands are prefixed with the exact same string, i.e.static String
getClassNameWithBrackets(Object item)
create a string that gets the class simple name and surrounds them with bracketsstatic String
iterationPrefix(int iterationIndex)
Create a prefix for the logger so that all logging items specific to a particular traffic assignment run are prefixed with the exact same iteration string, i.e.static String
logActiveStateByClassName(Object item, boolean activate)
create a string that states if item is activated or deactivated based and provide the simple class namestatic void
LogFineIfNull(Object object, Logger logger, String message, Object... arguments)
Log fine message when nullstatic void
LogSevereIfNull(Object object, Logger logger, String message, Object... arguments)
Log severe message when nullstatic <T> void
logWarningIf(Logger logger, String message, T testObject, Predicate<T> predicate)
log the given warning message if predicate holdsstatic String
networkLayerPrefix(long layerId)
Create a prefix for the logger so that all logging items specific to a particular network layer are prefixed with the exact same string, i.e.static String
networkPrefix(long networkId)
Create a prefix for the logger so that all logging items specific to a particular network are prefixed with the exact same string, i.e.static String
odPathSetsPrefix(long odPathSetsId)
Create a prefix for the logger so that all logging items specific to a particular od path sets are prefixed with the exact same string, i.e.static String
outputFormatterPrefix(long outputFormatterId)
Create a prefix for the logger so that all logging items specific to a particular output formatters are prefixed with the exact same string, i.e.static String
projectPrefix(long projectId)
Create a prefix for the logger so that all logging items specific to a particular project are prefixed with the exact same string, i.e.static String
routedServiceLayerPrefix(long routedServiceLayerId)
Create a prefix for the logger so that all logging items specific to a particular routed services layer are prefixed with the exact same string, i.e.static String
routedServicesPrefix(long routedServicesId)
Create a prefix for the logger so that all logging items specific to a particular routed services are prefixed with the exact same string, i.e.static String
runIdPrefix(long runId)
Create a prefix for the logger so that all logging items specific to a particular traffic assignment run are prefixed with the exact same string, i.e.static String
serviceNetworkLayerPrefix(long serviceNetworkLayerId)
Create a prefix for the logger so that all logging items specific to a particular service network layer are prefixed with the exact same string, i.e.static String
serviceNetworkPrefix(long serviceNetworkId)
Create a prefix for the logger so that all logging items specific to a particular service network are prefixed with the exact same string, i.e.static String
surround(String theString, char c, int repeat)
surround the string with repetitions of given characterstatic String
surroundwithBrackets(String message)
Surround string with brackets "[%s]"static String
timePeriodPrefix(TimePeriod timePeriod)
Create a prefix for the logger so that all logging items specific to a particular time period are prefixed with the exact same string, i.e.static String
zoningPrefix(long zoningId)
Create a prefix for the logger so that all logging items specific to a particular zoning are prefixed with the exact same string, i.e.
-
-
-
Method Detail
-
surroundwithBrackets
public static String surroundwithBrackets(String message)
Surround string with brackets "[%s]"- Parameters:
message
- to surround with brackets- Returns:
- bracketed string
-
runIdPrefix
public static String runIdPrefix(long runId)
Create a prefix for the logger so that all logging items specific to a particular traffic assignment run are prefixed with the exact same string, i.e.[run id: <id> ]
- Parameters:
runId
- the run id- Returns:
- runId prefix
-
projectPrefix
public static String projectPrefix(long projectId)
Create a prefix for the logger so that all logging items specific to a particular project are prefixed with the exact same string, i.e.[project id: <id> ]
- Parameters:
projectId
- the project id- Returns:
- project prefix
-
networkPrefix
public static String networkPrefix(long networkId)
Create a prefix for the logger so that all logging items specific to a particular network are prefixed with the exact same string, i.e.[network id: <id> ]
- Parameters:
networkId
- the network id- Returns:
- network prefix
-
networkLayerPrefix
public static String networkLayerPrefix(long layerId)
Create a prefix for the logger so that all logging items specific to a particular network layer are prefixed with the exact same string, i.e.[n-layer id: <id> ]
- Parameters:
layerId
- the network layerid- Returns:
- network layer prefix
-
zoningPrefix
public static String zoningPrefix(long zoningId)
Create a prefix for the logger so that all logging items specific to a particular zoning are prefixed with the exact same string, i.e.[zoning id: <id> ]
- Parameters:
zoningId
- the zoning id- Returns:
- zoning prefix
-
demandsPrefix
public static String demandsPrefix(long demandsId)
Create a prefix for the logger so that all logging items specific to a particular demands are prefixed with the exact same string, i.e.[demands id: <id> ]
- Parameters:
demandsId
- the demands id- Returns:
- demands prefix
-
serviceNetworkPrefix
public static String serviceNetworkPrefix(long serviceNetworkId)
Create a prefix for the logger so that all logging items specific to a particular service network are prefixed with the exact same string, i.e.[services network id: <id> ]
- Parameters:
serviceNetworkId
- the id- Returns:
- service network prefix
-
serviceNetworkLayerPrefix
public static String serviceNetworkLayerPrefix(long serviceNetworkLayerId)
Create a prefix for the logger so that all logging items specific to a particular service network layer are prefixed with the exact same string, i.e.[s_layer id: <id> ]
- Parameters:
serviceNetworkLayerId
- the id- Returns:
- service network prefix
-
routedServicesPrefix
public static String routedServicesPrefix(long routedServicesId)
Create a prefix for the logger so that all logging items specific to a particular routed services are prefixed with the exact same string, i.e.[routed services id: <id> ]
- Parameters:
routedServicesId
- the routed services id- Returns:
- routed services prefix
-
routedServiceLayerPrefix
public static String routedServiceLayerPrefix(long routedServiceLayerId)
Create a prefix for the logger so that all logging items specific to a particular routed services layer are prefixed with the exact same string, i.e.[rs_layer id: <id> ]
- Parameters:
routedServiceLayerId
- the routed services id- Returns:
- routed services prefix
-
odPathSetsPrefix
public static String odPathSetsPrefix(long odPathSetsId)
Create a prefix for the logger so that all logging items specific to a particular od path sets are prefixed with the exact same string, i.e.[od path sets id: <id> ]
- Parameters:
odPathSetsId
- the odPathSets id- Returns:
- od path sets Prefix
-
outputFormatterPrefix
public static String outputFormatterPrefix(long outputFormatterId)
Create a prefix for the logger so that all logging items specific to a particular output formatters are prefixed with the exact same string, i.e.[output formatter id: <id> ]
- Parameters:
outputFormatterId
- the output formatter id- Returns:
- output formatter prefix
-
timePeriodPrefix
public static String timePeriodPrefix(TimePeriod timePeriod)
Create a prefix for the logger so that all logging items specific to a particular time period are prefixed with the exact same string, i.e.[time period : <external id> (id <id>) ]
- Parameters:
timePeriod
- the time period to create it for- Returns:
- time period prefix
-
iterationPrefix
public static String iterationPrefix(int iterationIndex)
Create a prefix for the logger so that all logging items specific to a particular traffic assignment run are prefixed with the exact same iteration string, i.e.[i=<id> ]
- Parameters:
iterationIndex
- the iteration index- Returns:
- iteration prefix
-
logActiveStateByClassName
public static String logActiveStateByClassName(Object item, boolean activate)
create a string that states if item is activated or deactivated based and provide the simple class name- Parameters:
item
- to (de)activateactivate
- indicate to activate or deactive- Returns:
- the string (de)activated :
<simple class name>
-
getClassNameWithBrackets
public static String getClassNameWithBrackets(Object item)
create a string that gets the class simple name and surrounds them with brackets- Parameters:
item
- to to apply- Returns:
- the string
[<class simple name>]
-
surround
public static String surround(String theString, char c, int repeat)
surround the string with repetitions of given character- Parameters:
theString
- to surroundc
- character to usrepeat
- num reptitions on either side- Returns:
- created string
-
LogSevereIfNull
public static void LogSevereIfNull(Object object, Logger logger, String message, Object... arguments)
Log severe message when null- Parameters:
object
- to checklogger
- to usemessage
- to logarguments
- arguments of message
-
LogFineIfNull
public static void LogFineIfNull(Object object, Logger logger, String message, Object... arguments)
Log fine message when null- Parameters:
object
- to checklogger
- to usemessage
- to logarguments
- arguments of message
-
logWarningIf
public static <T> void logWarningIf(Logger logger, String message, T testObject, Predicate<T> predicate)
log the given warning message if predicate holds- Type Parameters:
T
- type of test object to aply predicate to- Parameters:
logger
- the logger to usemessage
- to log if not too close to bounding boxtestObject
- to test onpredicate
- to use
-
-