use of ch.qos.logback.classic.spi.ILoggingEvent in project sling by apache.
the class SlingConfigurationPrinter method dumpLogFileSummary.
private void dumpLogFileSummary(PrintWriter pw, Collection<Appender<ILoggingEvent>> appenders) {
pw.println("Summary");
pw.println("=======");
pw.println();
int counter = 0;
final String rootDir = logbackManager.getRootDir();
for (Appender<ILoggingEvent> appender : appenders) {
if (appender instanceof FileAppender) {
File file = new File(((FileAppender) appender).getFile());
final File dir = file.getParentFile();
final String baseName = file.getName();
String absolutePath = dir.getAbsolutePath();
String displayName = ((FileAppender) appender).getFile();
if (absolutePath.startsWith(rootDir)) {
displayName = baseName;
}
pw.printf("%d. %s %n", ++counter, displayName);
final File[] files = getRotatedFiles((FileAppender) appender, -1);
for (File f : files) {
pw.printf(" - %s, %s, %s %n", f.getName(), humanReadableByteCount(f.length()), getModifiedDate(f));
}
}
}
pw.println();
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project sling by apache.
the class SlingConfigurationPrinter method printConfiguration.
/**
* @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
*/
@SuppressWarnings("UnusedDeclaration")
public void printConfiguration(PrintWriter printWriter, String mode) {
LogbackManager.LoggerStateContext ctx = logbackManager.determineLoggerState();
int numOfLines = getNumOfLines();
Tailer tailer = new Tailer(printWriter, numOfLines);
dumpLogFileSummary(printWriter, ctx.getAllAppenders());
if (!MODE_ZIP.equals(mode)) {
for (Appender<ILoggingEvent> appender : ctx.getAllAppenders()) {
if (appender instanceof FileAppender) {
final File file = new File(((FileAppender) appender).getFile());
if (file.exists()) {
printWriter.print("Log file ");
printWriter.println(file.getAbsolutePath());
printWriter.println("--------------------------------------------------");
if (numOfLines < 0) {
includeWholeFile(printWriter, file);
} else {
try {
tailer.tail(file);
} catch (IOException e) {
logbackManager.getLogConfigManager().internalFailure("Error occurred " + "while processing log file " + file, e);
}
}
printWriter.println();
}
}
}
}
dumpLogbackStatus(logbackManager, printWriter);
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project sling by apache.
the class SlingConfigurationPrinter method getAttachments.
/**
* Attempts to determine all log files created even via rotation.
* if some complex rotation logic is used where rotated file get different names
* or get created in different directory then those files would not be
* included
*
* @see org.apache.felix.webconsole.AttachmentProvider#getAttachments(String)
*/
@SuppressWarnings("UnusedDeclaration")
public URL[] getAttachments(String mode) {
// we only provide urls for mode zip
if (MODE_ZIP.equals(mode)) {
final List<URL> urls = new ArrayList<URL>();
LogbackManager.LoggerStateContext ctx = logbackManager.determineLoggerState();
for (Appender<ILoggingEvent> appender : ctx.getAllAppenders()) {
if (appender instanceof FileAppender) {
final File[] files = getRotatedFiles((FileAppender) appender, getMaxOldFileCount());
for (File f : files) {
try {
urls.add(f.toURI().toURL());
} catch (MalformedURLException mue) {
// we just ignore this file then
}
}
}
}
if (urls.size() > 0) {
return urls.toArray(new URL[urls.size()]);
}
}
return null;
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project jadx by skylot.
the class JadxCLIArgs method process.
private boolean process() {
if (isPrintHelp()) {
printUsage();
return false;
}
try {
if (threadsCount <= 0) {
throw new JadxException("Threads count must be positive");
}
if (files != null) {
for (String fileName : files) {
File file = new File(fileName);
if (file.exists()) {
input.add(file);
} else {
throw new JadxException("File not found: " + file);
}
}
}
if (input.size() > 1) {
throw new JadxException("Only one input file is supported");
}
if (outDirName != null) {
outputDir = new File(outDirName);
}
if (isVerbose()) {
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
// remove INFO ThresholdFilter
Appender<ILoggingEvent> appender = rootLogger.getAppender("STDOUT");
if (appender != null) {
appender.clearAllFilters();
}
}
} catch (JadxException e) {
System.err.println("ERROR: " + e.getMessage());
printUsage();
return false;
}
return true;
}
use of ch.qos.logback.classic.spi.ILoggingEvent in project spring-boot by spring-projects.
the class LevelRemappingAppenderTests method mockLogEvent.
private ILoggingEvent mockLogEvent(Level level) {
ILoggingEvent event = mock(ILoggingEvent.class);
given(event.getLevel()).willReturn(level);
return event;
}
Aggregations