View Javadoc

1   package com.github.triceo.splitlog.api;
2   
3   import java.util.Date;
4   import java.util.List;
5   
6   /**
7    * A set of lines from the watched file, that is likely to constitute a single
8    * log message. No two messages are allowed to be equal, unless they have the
9    * same {@link #getUniqueId()}.
10   */
11  public interface Message {
12  
13      /**
14       * Get the date that this message was logged on.
15       *
16       * @return Newly constructed instance of {@link Date} with the message log
17       *         timestamp.
18       */
19      Date getDate();
20  
21      /**
22       * Get data about exception included in this message.
23       *
24       * @return Exception data, if {@link #hasException()} returns true. Null in
25       *         any other case.
26       */
27      ExceptionDescriptor getExceptionDescriptor();
28  
29      /**
30       * Get each line of the message.
31       *
32       * @return Unmodifiable representation of lines in this message, exactly as
33       *         were received.
34       */
35      List<String> getLines();
36  
37      /**
38       * Get each line of the message, with metadata stripped out.
39       *
40       * @return Unmodifiable representation of text of the message.
41       */
42      List<String> getLinesWithoutMetadata();
43  
44      /**
45       * Will return the name of the logger that was used to write the log
46       * message.
47       *
48       * @return Empty string if none found.
49       */
50      String getLogger();
51  
52      /**
53       * Return a message that preceded this one in the same log stream.
54       *
55       * @return Null if there was no such message, the message already got GC'd,
56       *         or <code>{@link #getType()} == {@link MessageType#TAG}</code>.
57       */
58      Message getPreviousMessage();
59  
60      MessageSeverity getSeverity();
61  
62      MessageType getType();
63  
64      /**
65       * Unique ID of the message, that can be used to compare messages in the
66       * order of their arrival into this tool.
67       *
68       * @return ID of the message, guaranteed to be unique for every message, and
69       *         increasing from message to message.
70       */
71      long getUniqueId();
72  
73      boolean hasException();
74  
75  }