Class LogFiles

java.lang.Object
io.github.jbastgen.stemma.app.io.LogFiles

public final class LogFiles extends Object
Finding, reading and searching the daily log files (stemma-YYYY-MM-DD.log) for the log page of the About dialog.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    What was read.
    static final record 
    The lines that contain the search text, without regard to case; all lines when it is blank.
    static enum 
    Which log: the one of the application, or the one of the requests to AI services.
    static enum 
    Which lines of the log to show: all, those of level info and above, or only warnings and errors.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    How much of a file is read: the end of it, which is where the news is.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    lastLines(String text, int count)
    The last count lines of the text (all of it if it is shorter).
    static List<Path>
    list(Path dir)
    The application log files in dir, newest first; empty if the folder is missing or cannot be read.
    static List<Path>
    list(Path dir, LogFiles.Kind kind)
    The log files of one kind in dir, newest first.
    static String
    size(long bytes)
    "12 KB", "3.4 MB".
    tail(Path file, long maxBytes)
    Reads the last maxBytes of the file as text (UTF-8); a line that is cut in the middle is dropped.
    view(String text, LogFiles.Level level, String query)
    What the log page shows: the lines of at least this level that also contain the search text.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_BYTES

      public static final long MAX_BYTES
      How much of a file is read: the end of it, which is where the news is.
      See Also:
  • Method Details

    • list

      public static List<Path> list(Path dir)
      The application log files in dir, newest first; empty if the folder is missing or cannot be read.
    • list

      public static List<Path> list(Path dir, LogFiles.Kind kind)
      The log files of one kind in dir, newest first.
    • tail

      public static LogFiles.Content tail(Path file, long maxBytes) throws IOException
      Reads the last maxBytes of the file as text (UTF-8); a line that is cut in the middle is dropped.
      Throws:
      IOException
    • view

      public static LogFiles.Filtered view(String text, LogFiles.Level level, String query)
      What the log page shows: the lines of at least this level that also contain the search text. A line without a level (the lines of a stack trace) belongs to the line before it and is shown with it.
    • lastLines

      public static String lastLines(String text, int count)
      The last count lines of the text (all of it if it is shorter).
    • size

      public static String size(long bytes)
      "12 KB", "3.4 MB".