Class Configuration.LoggerWriter

java.lang.Object
java.io.Writer
org.noise_planet.noisemodelling.webserver.Configuration.LoggerWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Enclosing class:
Configuration

public static class Configuration.LoggerWriter extends Writer
A Writer implementation that redirects output to an SLF4J Logger instance. This class is useful for redirecting output from a Writer to a logging framework. It buffers the output and logs it when the buffer is flushed or closed.
  • Constructor Details

    • LoggerWriter

      public LoggerWriter(org.slf4j.Logger logger)
      Constructs a new LoggerWriter instance that redirects output to the specified Logger.
      Parameters:
      logger - the SLF4J Logger instance to which output will be redirected
  • Method Details

    • write

      public void write(char[] cbuf, int off, int len) throws IOException
      Writes a portion of an array of characters to the buffer.
      Specified by:
      write in class Writer
      Parameters:
      cbuf - the array of characters to write
      off - the offset from which to start writing
      len - the number of characters to write
      Throws:
      IOException - if an I/O error occurs
    • flush

      public void flush() throws IOException
      Flushes the buffer and logs its contents to the Logger.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
      Throws:
      IOException - if an I/O error occurs
    • close

      public void close() throws IOException
      Closes the Writer, but does not perform any actual closing operation.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
      Throws:
      IOException - if an I/O error occurs