Class BasicLogger

java.lang.Object
VASSAL.build.module.BasicLogger
All Implemented Interfaces:
Buildable, GameComponent, CommandEncoder, Logger

public class BasicLogger extends Object implements Logger, Buildable, GameComponent, CommandEncoder
BasicLogger deals with VLOG Vassal Log files (i.e. NOT the errorLog--see below):
(1) Starts/stops logging to a VLOG file.
(2) Supplies prompt dialogs related to starting logfiles
(3) Steps through VLOG files ("step forward") button
(4) Executes the "UNDO" action when user clicks that Undo button
(5) Provides configurers to GlobalOptions for the Undo and Step Forward buttons

For the errorLog file see Logger, e.g.:
org.slf4j.Logger log = LoggerFactory.getLogger(Console.class);
log.error("write to errorlog as an error")
log.warning("write a warning")
log.info("write some info")
  • Field Details

  • Constructor Details

    • BasicLogger

      public BasicLogger()
  • Method Details

    • build

      public void build(Element e)
      Presently no XML attributes or subcomponents to be built
      Specified by:
      build in interface Buildable
      Parameters:
      e - the XML element containing the object data
    • getNamedKeyStrokes

      public List<NamedKeyStroke> getNamedKeyStrokes()
      Since the configurers for our keystrokes are farmed out to GlobalOptions, this provides a way for GlobalOptions to find out about them (when being searched, etc)
      Returns:
      List of keystrokes used by the Basic Logger
    • addTo

      public void addTo(Buildable b)
      Expects to be added to a GameModule. Adds Undo, Step, and End Log buttons to the the control window toolbar. Registers KeyStrokeListeners for hotkey equivalents of each button.
      Specified by:
      addTo in interface Buildable
      Parameters:
      b - parent Buildable to add this component to as a subcomponent.
    • getBuildElement

      public Element getBuildElement(Document doc)
      Specified by:
      getBuildElement in interface Buildable
      Parameters:
      doc - XML file
      Returns:
      an XML element from which this component can be built
    • add

      public void add(Buildable b)
      Description copied from interface: Buildable
      Adds a child component. Both this method and Buildable.addTo(VASSAL.build.Buildable) are invoked when adding a child to a parent
      Specified by:
      add in interface Buildable
      Parameters:
      b - Child to attach to this buildable as a subcomponent
    • remove

      public void remove(Buildable b)
    • setMultiPlayer

      public void setMultiPlayer(boolean multiPlayer)
    • isMultiPlayer

      public boolean isMultiPlayer()
    • setup

      public void setup(boolean startingGame)
      Our setup method is called by GameState whenever a game starts or ends.
      Specified by:
      setup in interface GameComponent
      Parameters:
      startingGame - True if a new game starting, false if a game is ending/closing
    • isLogging

      public boolean isLogging()
      Returns:
      true if we're currently logging the game to a VLOG file
    • isReplaying

      public boolean isReplaying()
      Returns:
      true if we're currently replaying a VLOG file, that has unexecuted "step forwards" remaining
    • getRestoreCommand

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
      Specified by:
      getRestoreCommand in interface GameComponent
    • enableDrawing

      public void enableDrawing(boolean show)
    • step

      protected void step()
      Step forward through the currently replaying vlog logfile, by getting the next Command and executing it.
    • queryNewLogFile

      public void queryNewLogFile(boolean atStart)
      Check if user would like to create a new logfile (only prompts if the appropriate preference is on)
      Parameters:
      atStart - true if prompting because we're just starting a session; false if prompting because we just finished replaying a logfile.
    • queryNewLogFile

      public void queryNewLogFile(boolean atStart, boolean fastForwarded)
      Check if user would like to create a new logfile (only prompts if the appropriate preference is on)
      Parameters:
      atStart - true if prompting because we're just starting a session; false if prompting because we just finished replaying a logfile.
      fastForwarded - true if we have fast forwarded
    • write

      public void write() throws IOException
      Write the logfile to a file. The filename will have been selected when the logfile was begun.
      Throws:
      IOException
    • beginOutput

      protected void beginOutput()
    • blockUndo

      public void blockUndo(int block)
      Mark the current command as a no-undo-past-this-point.
      Parameters:
      block - number extra command(s) into the future to block (when this is being executed "from inside a command")
    • undo

      protected void undo()
      This handles the UNDO button, executing the actual "Undo".
    • isUndoInProgress

      public boolean isUndoInProgress()
    • setUndoInProgress

      public void setUndoInProgress(boolean undoInProgress)
    • log

      public void log(Command c)
      Logs a Command to output
      Specified by:
      log in interface Logger
      Parameters:
      c - Command to be logged
    • hasMoreCommands

      public boolean hasMoreCommands()
      Returns:
      true if there are Input Steps yet to be replayed
    • encode

      public String encode(Command c)
      Recognizes a logging command. The logging command is a wrapper around an ordinary Command indicating that the wrapped command should be stored and executed in sequence (when the Step button is pressed)
      Specified by:
      encode in interface CommandEncoder
    • decode

      public Command decode(String command)
      Description copied from interface: CommandEncoder
      Translate a String into a Command
      Specified by:
      decode in interface CommandEncoder