public class CategoryLogger extends Object
CategoryLogger.always().error(exception, "Parameter {} did not initialize correctly", param1.toString());It is also possible to indicate the category / categories for the message, which will only be logged if at least one of the indicated categories is turned on with addLogCategory() or setLogCategories(), or if one of the added or set LogCategories is LogCategory.ALL:
CategoryLogger.filter(Cat.BASE).debug("Parameter {} initialized correctly", param1.toString());Copyright (c) 2003-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
Modifier and Type | Class and Description |
---|---|
static class |
CategoryLogger.DelegateLogger
DelegateLogger class that takes care of actually logging the message and/or exception.
|
Modifier and Type | Field and Description |
---|---|
protected static Set<LogCategory> |
categories
The categories to log.
|
static String |
DEFAULT_MESSAGE_FORMAT
The default message format.
|
protected static CategoryLogger.DelegateLogger |
delegateLogger
The delegate logger instance that does the actual logging work, after a positive filter outcome.
|
protected static CategoryLogger.DelegateLogger |
noLogger
The delegate logger that returns immediately after a negative filter outcome.
|
Modifier | Constructor and Description |
---|---|
protected |
CategoryLogger() |
Modifier and Type | Method and Description |
---|---|
static void |
addLogCategory(LogCategory logCategory)
Add a category to be logged to the Writers.
|
static CategoryLogger.DelegateLogger |
always()
The "pass" filter that will result in always trying to log.
|
protected static void |
create()
Create a new logger for the system console.
|
static CategoryLogger.DelegateLogger |
filter(LogCategory... logCategories)
Check whether the provided categories contain one or more categories that need to be logged.
|
static CategoryLogger.DelegateLogger |
filter(LogCategory logCategory)
Check whether the provided category needs to be logged.
|
static CategoryLogger.DelegateLogger |
filter(Set<LogCategory> logCategories)
Check whether the provided categories contain one or more categories that need to be logged.
|
static void |
removeLogCategory(LogCategory logCategory)
Remove a category to be logged to the Writers.
|
static void |
setAllLogLevel(org.pmw.tinylog.Level newLevel)
Set a new logging level for all registered writers.
|
static void |
setAllLogMessageFormat(String newMessageFormat)
Set a new logging format for the message lines of all writers.
|
static void |
setLogCategories(LogCategory... newLogCategories)
Set the categories to be logged to the Writers.
|
static void |
setLogLevel(org.pmw.tinylog.writers.Writer writer,
org.pmw.tinylog.Level newLevel)
Set a new logging level for one of the registered writers.
|
static void |
setLogMessageFormat(org.pmw.tinylog.writers.Writer writer,
String newMessageFormat)
Set a new logging format for the message lines of a writer.
|
public static final String DEFAULT_MESSAGE_FORMAT
protected static Set<LogCategory> categories
protected static CategoryLogger.DelegateLogger delegateLogger
protected static CategoryLogger.DelegateLogger noLogger
protected static void create()
public static void setAllLogMessageFormat(String newMessageFormat)
newMessageFormat
- the new formatting pattern to use for all registered writerspublic static void setAllLogLevel(org.pmw.tinylog.Level newLevel)
newLevel
- the new log level for all registered writerspublic static void setLogMessageFormat(org.pmw.tinylog.writers.Writer writer, String newMessageFormat)
writer
- the writer to change the message format fornewMessageFormat
- the new formatting pattern to use for all registered writerspublic static void setLogLevel(org.pmw.tinylog.writers.Writer writer, org.pmw.tinylog.Level newLevel)
writer
- the writer to change the log level fornewLevel
- the new log level for the writerpublic static void addLogCategory(LogCategory logCategory)
logCategory
- the LogCategory to addpublic static void removeLogCategory(LogCategory logCategory)
logCategory
- the LogCategory to removepublic static void setLogCategories(LogCategory... newLogCategories)
newLogCategories
- the LogCategories to set, replacing the previous onespublic static CategoryLogger.DelegateLogger always()
public static CategoryLogger.DelegateLogger filter(LogCategory logCategory)
logCategory
- the category to check for.public static CategoryLogger.DelegateLogger filter(LogCategory... logCategories)
logCategories
- LogCategory...; elements or array with the categories to check forpublic static CategoryLogger.DelegateLogger filter(Set<LogCategory> logCategories)
logCategories
- Set<LogCategory>; the categories to check forCopyright © 2014–2018 Delft University of Technology. All rights reserved.