Package VASSAL.build.module
Class BasicLogger
java.lang.Object
VASSAL.build.module.BasicLogger
- All Implemented Interfaces:
Buildable
,GameComponent
,CommandEncoder
,Logger
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
For the errorLog file see
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")
(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")
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
class
class
static class
A Command that records whether or not an Undo is in progress. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected Command
protected int
static final String
protected Action
static final String
protected SaveMetaData
protected Action
protected int
protected int
protected File
static final String
static final String
static final String
static final String
protected static final String
protected Action
static final String
protected static final String
protected Action
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child component.void
Expects to be added to aGameModule
.protected void
void
blockUndo
(int block) Mark the current command as a no-undo-past-this-point.void
Presently no XML attributes or subcomponents to be builtTranslate a String into aCommand
void
enableDrawing
(boolean show) Recognizes a logging command.getBuildElement
(Document doc) 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)When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullboolean
boolean
boolean
boolean
boolean
void
Logs a Command to outputvoid
queryNewLogFile
(boolean atStart) Check if user would like to create a new logfile (only prompts if the appropriate preference is on)void
queryNewLogFile
(boolean atStart, boolean fastForwarded) Check if user would like to create a new logfile (only prompts if the appropriate preference is on)void
void
setMultiPlayer
(boolean multiPlayer) void
setUndoInProgress
(boolean undoInProgress) void
setup
(boolean startingGame) Our setup method is called by GameState whenever a game starts or ends.protected void
step()
Step forward through the currently replaying vlog logfile, by getting the nextCommand
and executing it.protected void
undo()
This handles the UNDO button, executing the actual "Undo".void
write()
Write the logfile to a file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
isMandatory, isMovable, isUnique
-
Field Details
-
BEGIN
- See Also:
-
END
- See Also:
-
LOG
- See Also:
-
UNDO
- See Also:
-
PROMPT_NEW_LOG
- See Also:
-
PROMPT_NEW_LOG_START
- See Also:
-
PROMPT_NEW_LOG_END
- See Also:
-
PROMPT_LOG_COMMENT
- See Also:
-
STEP_ICON
- See Also:
-
UNDO_ICON
- See Also:
-
logInput
-
logOutput
-
nextInput
protected int nextInput -
nextUndo
protected int nextUndo -
dontUndoPast
protected int dontUndoPast -
beginningState
-
outputFile
-
stepAction
-
metadata
-
undoAction
-
endLogAction
-
newLogAction
-
-
Constructor Details
-
BasicLogger
public BasicLogger()
-
-
Method Details
-
build
-
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
Expects to be added to aGameModule
. AddsUndo
,Step
, andEnd Log
buttons to the the control window toolbar. RegistersKeyStrokeListener
s for hotkey equivalents of each button. -
getBuildElement
- Specified by:
getBuildElement
in interfaceBuildable
- Parameters:
doc
- XML file- Returns:
- an XML element from which this component can be built
-
add
Description copied from interface:Buildable
Adds a child component. Both this method andBuildable.addTo(VASSAL.build.Buildable)
are invoked when adding a child to a parent -
remove
-
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 interfaceGameComponent
- 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
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
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 interfaceGameComponent
-
enableDrawing
public void enableDrawing(boolean show) -
step
protected void step()Step forward through the currently replaying vlog logfile, by getting the nextCommand
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
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
-
hasMoreCommands
public boolean hasMoreCommands()- Returns:
- true if there are Input Steps yet to be replayed
-
encode
Recognizes a logging command. The logging command is a wrapper around an ordinaryCommand
indicating that the wrapped command should be stored and executed in sequence (when theStep
button is pressed)- Specified by:
encode
in interfaceCommandEncoder
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-