1 package com.github.triceo.splitlog.api; 2 3 import java.util.Date; 4 import java.util.List; 5 6 /** 7 * The purpose of classes implementing this interface is to interpret the log 8 * files. Each implementation should be familiar with one type of log file (i.e. 9 * JBoss logging or Logback) and be able to interpret the messages and their 10 * lines. 11 */ 12 public interface TailSplitter { 13 14 /** 15 * Read the message and find the date when the message was submitted. 16 * 17 * @param raw 18 * Raw, untreated lines of the message. 19 * @return Date from the message, or null if not found. 20 */ 21 Date determineDate(final List<String> raw); 22 23 /** 24 * Read the message and try to identify an exception stack trace within. 25 * 26 * @param raw 27 * Raw, untreated lines of the message. 28 * @return Exception data if found, null otherwise. 29 */ 30 ExceptionDescriptor determineException(final List<String> raw); 31 32 /** 33 * Messages in the log can contain information as to what logged them. This 34 * would typically be a Java package name. This method will try to return 35 * that. 36 * 37 * @param raw 38 * Raw, untreated lines of the message. 39 * @return Null if not found. 40 */ 41 String determineLogger(final List<String> raw); 42 43 /** 44 * Read the message and try to find its severity. 45 * 46 * @param raw 47 * Raw, untreated lines of the message. 48 * @return Severity included in the message, {@link MessageSeverity#UNKNOWN} 49 * otherwise. 50 */ 51 MessageSeverity determineSeverity(final List<String> raw); 52 53 /** 54 * Read the message and try to find its type. 55 * 56 * @param raw 57 * Raw, untreated lines of the message. 58 * @return Type guessed from the message, {@link MessageType#LOG} if 59 * undetermined. 60 */ 61 MessageType determineType(final List<String> raw); 62 63 /** 64 * Whether or not this particular line from the log starts a new log 65 * message. If so, it will be used to trigger a {@link Message} being 66 * produced and possibly stored. 67 * 68 * @param line 69 * Line from the log. 70 * @return True if this is the first line of a new log message. 71 */ 72 boolean isStartingLine(final String line); 73 74 /** 75 * Take a line from the log and attempt to strip it of metadata, such as 76 * severity, type and date. 77 * 78 * @param line 79 * Line from the log. 80 * @return The same line, stripped of metadata. Usually just the actual 81 * information being logged. 82 */ 83 String stripOfMetadata(final String line); 84 85 }