Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
SLF4J API Source Code
SLF4J API is a simple API that allows to plug in any desired logging library at deployment time.
Here is the source code for SLF4J API 2.0.4. You can download its pre-compiled version slf4j-api-2.0.4.jar at SLF4J Download Website.
✍: FYIcenter.com
⏎ org/slf4j/helpers/NormalizedParameters.java
package org.slf4j.helpers; import org.slf4j.event.LoggingEvent; /** * Holds normalized call parameters. * * Includes utility methods such as {@link #normalize(String, Object[], Throwable)} to help the normalization of parameters. * * @author ceki * @since 2.0 */ public class NormalizedParameters { final String message; final Object[] arguments; final Throwable throwable; public NormalizedParameters(String message, Object[] arguments, Throwable throwable) { this.message = message; this.arguments = arguments; this.throwable = throwable; } public NormalizedParameters(String message, Object[] arguments) { this(message, arguments, null); } public String getMessage() { return message; } public Object[] getArguments() { return arguments; } public Throwable getThrowable() { return throwable; } /** * Helper method to determine if an {@link Object} array contains a * {@link Throwable} as last element * * @param argArray The arguments off which we want to know if it contains a * {@link Throwable} as last element * @return if the last {@link Object} in argArray is a {@link Throwable} this * method will return it, otherwise it returns null */ public static Throwable getThrowableCandidate(final Object[] argArray) { if (argArray == null || argArray.length == 0) { return null; } final Object lastEntry = argArray[argArray.length - 1]; if (lastEntry instanceof Throwable) { return (Throwable) lastEntry; } return null; } /** * Helper method to get all but the last element of an array * * @param argArray The arguments from which we want to remove the last element * * @return a copy of the array without the last element */ public static Object[] trimmedCopy(final Object[] argArray) { if (argArray == null || argArray.length == 0) { throw new IllegalStateException("non-sensical empty or null argument array"); } final int trimmedLen = argArray.length - 1; Object[] trimmed = new Object[trimmedLen]; if (trimmedLen > 0) { System.arraycopy(argArray, 0, trimmed, 0, trimmedLen); } return trimmed; } /** * This method serves to normalize logging call invocation parameters. * * More specifically, if a throwable argument is not supplied directly, it * attempts to extract it from the argument array. */ public static NormalizedParameters normalize(String msg, Object[] arguments, Throwable t) { if (t != null) { return new NormalizedParameters(msg, arguments, t); } if (arguments == null || arguments.length == 0) { return new NormalizedParameters(msg, arguments, t); } Throwable throwableCandidate = NormalizedParameters.getThrowableCandidate(arguments); if (throwableCandidate != null) { Object[] trimmedArguments = MessageFormatter.trimmedCopy(arguments); return new NormalizedParameters(msg, trimmedArguments, throwableCandidate); } else { return new NormalizedParameters(msg, arguments); } } public static NormalizedParameters normalize(LoggingEvent event) { return normalize(event.getMessage(), event.getArgumentArray(), event.getThrowable()); } }
⏎ org/slf4j/helpers/NormalizedParameters.java
Or download all of them as a single archive file:
File name: slf4j-api-2.0.4-sources.jar File size: 70304 bytes Release date: 2022-11-17 Download
⇒ Source Code for SLF4J Simple Logging
⇐ Downloading SLF4J Components
2020-02-13, 28617👍, 2💬
Popular Posts:
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
HttpComponents Client Source Code Files are provided in the source package file, httpcomponents-clie...
XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with ...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
How to download and install JDK (Java Development Kit) 8? If you want to write Java applications, yo...