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:
Source Code for SLF4J 1.7.31 Extensions
SLF4J Extensions is a library of 3 components: Profiler, Extended logger, Event Logging, Logging added with Java agent.
Here is the source code for SLF4J Extensions You can download its pre-compiled version slf4j-ext-1.7.31.jar at SLF4J Download Website.
✍: FYIcenter.com
⏎ org/slf4j/ext/XLogger.java
/** * Copyright (c) 2004-2011 QOS.ch * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.slf4j.ext; import org.slf4j.Logger; import org.slf4j.Marker; import org.slf4j.MarkerFactory; import org.slf4j.helpers.FormattingTuple; import org.slf4j.helpers.MessageFormatter; import org.slf4j.spi.LocationAwareLogger; /** * A utility that provides standard mechanisms for logging certain kinds of * activities. * * @author Ralph Goers * @author Ceki Gülcü */ public class XLogger extends LoggerWrapper implements Logger { private static final String FQCN = XLogger.class.getName(); static Marker FLOW_MARKER = MarkerFactory.getMarker("FLOW"); static Marker ENTRY_MARKER = MarkerFactory.getMarker("ENTRY"); static Marker EXIT_MARKER = MarkerFactory.getMarker("EXIT"); static Marker EXCEPTION_MARKER = MarkerFactory.getMarker("EXCEPTION"); static Marker THROWING_MARKER = MarkerFactory.getMarker("THROWING"); static Marker CATCHING_MARKER = MarkerFactory.getMarker("CATCHING"); static String EXIT_MESSAGE_0 = "exit"; static String EXIT_MESSAGE_1 = "exit with ({})"; static String ENTRY_MESSAGE_0 = "entry"; static String ENTRY_MESSAGE_1 = "entry with ({})"; static String ENTRY_MESSAGE_2 = "entry with ({}, {})"; static String ENTRY_MESSAGE_3 = "entry with ({}, {}, {})"; static String ENTRY_MESSAGE_4 = "entry with ({}, {}, {}, {})"; static int ENTRY_MESSAGE_ARRAY_LEN = 5; static String[] ENTRY_MESSAGE_ARRAY = new String[ENTRY_MESSAGE_ARRAY_LEN]; static { ENTRY_MARKER.add(FLOW_MARKER); EXIT_MARKER.add(FLOW_MARKER); THROWING_MARKER.add(EXCEPTION_MARKER); CATCHING_MARKER.add(EXCEPTION_MARKER); ENTRY_MESSAGE_ARRAY[0] = ENTRY_MESSAGE_0; ENTRY_MESSAGE_ARRAY[1] = ENTRY_MESSAGE_1; ENTRY_MESSAGE_ARRAY[2] = ENTRY_MESSAGE_2; ENTRY_MESSAGE_ARRAY[3] = ENTRY_MESSAGE_3; ENTRY_MESSAGE_ARRAY[4] = ENTRY_MESSAGE_4; } public enum Level { TRACE("TRACE", LocationAwareLogger.TRACE_INT), DEBUG("DEBUG", LocationAwareLogger.DEBUG_INT), INFO("INFO", LocationAwareLogger.INFO_INT), WARN("WARN", LocationAwareLogger.WARN_INT), ERROR("ERROR", LocationAwareLogger.ERROR_INT); private final String name; private final int level; public String toString() { return this.name; } public int intValue() { return this.level; } private Level(String name, int level) { this.name = name; this.level = level; } } /** * Given an underlying logger, construct an XLogger * * @param logger * underlying logger */ public XLogger(Logger logger) { // If class B extends A, assuming B does not override method x(), the caller // of new B().x() is A and not B, see also // http://jira.qos.ch/browse/SLF4J-105 super(logger, LoggerWrapper.class.getName()); } /** * Log method entry. * * @param argArray * supplied parameters */ public void entry(Object... argArray) { if (instanceofLAL && logger.isTraceEnabled(ENTRY_MARKER)) { String messagePattern = null; if (argArray.length < ENTRY_MESSAGE_ARRAY_LEN) { messagePattern = ENTRY_MESSAGE_ARRAY[argArray.length]; } else { messagePattern = buildMessagePattern(argArray.length); } FormattingTuple tp = MessageFormatter.arrayFormat(messagePattern, argArray); ((LocationAwareLogger) logger).log(ENTRY_MARKER, FQCN, LocationAwareLogger.TRACE_INT, tp.getMessage(), argArray, tp.getThrowable()); } } /** * Log method exit */ public void exit() { if (instanceofLAL && logger.isTraceEnabled(ENTRY_MARKER)) { ((LocationAwareLogger) logger).log(EXIT_MARKER, FQCN, LocationAwareLogger.TRACE_INT, EXIT_MESSAGE_0, null, null); } } /** * Log method exit * * @param result * The result of the method being exited */ public <T> T exit(T result) { if (instanceofLAL && logger.isTraceEnabled(ENTRY_MARKER)) { FormattingTuple tp = MessageFormatter.format(EXIT_MESSAGE_1, result); ((LocationAwareLogger) logger).log(EXIT_MARKER, FQCN, LocationAwareLogger.TRACE_INT, tp.getMessage(), new Object[] { result }, tp.getThrowable()); } return result; } /** * Log an exception being thrown. The generated log event uses Level ERROR. * * @param throwable * the exception being caught. */ public <T extends Throwable> T throwing(T throwable) { if (instanceofLAL) { ((LocationAwareLogger) logger).log(THROWING_MARKER, FQCN, LocationAwareLogger.ERROR_INT, "throwing", null, throwable); } return throwable; } /** * Log an exception being thrown allowing the log level to be specified. * * @param level * the logging level to use. * @param throwable * the exception being caught. */ public <T extends Throwable> T throwing(Level level, T throwable) { if (instanceofLAL) { ((LocationAwareLogger) logger).log(THROWING_MARKER, FQCN, level.level, "throwing", null, throwable); } return throwable; } /** * Log an exception being caught. The generated log event uses Level ERROR. * * @param throwable * the exception being caught. */ public void catching(Throwable throwable) { if (instanceofLAL) { ((LocationAwareLogger) logger).log(CATCHING_MARKER, FQCN, LocationAwareLogger.ERROR_INT, "catching", null, throwable); } } /** * Log an exception being caught allowing the log level to be specified. * * @param level * the logging level to use. * @param throwable * the exception being caught. */ public void catching(Level level, Throwable throwable) { if (instanceofLAL) { ((LocationAwareLogger) logger).log(CATCHING_MARKER, FQCN, level.level, "catching", null, throwable); } } private static String buildMessagePattern(int len) { StringBuilder sb = new StringBuilder(); sb.append(" entry with ("); for (int i = 0; i < len; i++) { sb.append("{}"); if (i != len - 1) sb.append(", "); } sb.append(')'); return sb.toString(); } }
⏎ org/slf4j/ext/XLogger.java
Or download all of them as a single archive file:
File name: slf4j-ext-1.7.31-sources.jar File size: 40408 bytes Release date: 2021-06-17 Download
⇒ Source Code for SLF4J 1.7.31 Migrator
⇐ Source Code for SLF4J 1.7.31 Bridge to Log4J 1.3
2023-03-17, 2328👍, 0💬
Popular Posts:
JDK 11 jdk.internal.opt.jmod is the JMOD file for JDK 11 Internal Opt module. JDK 11 Internal Opt mo...
Smack is an Open Source XMPP (Jabber) client library for instant messaging and presence. A pure Java...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was develo...
How to run "jar" command from JDK tools.jar file? "jar" is the JAR (Java Archive) file management co...
The Digester package lets you configure an XML -> Java object mapping module, which triggers certain...