BaseDebugLogAction
BaseDebugLogAction is an abstract base class for actions that log messages to the Unity Console and, in the editor, the FSM Log.
It provides the shared logging behavior used by actions such as DebugLog and DebugLogVariable.
Core Functionality
The class provides:
Logging Types
Defines an enum Type with three severity levels:
Info: Standard informational messagesWarning: Warning messages that indicate potential issuesError: Error messages that indicate problems requiring attention
Logging Method
Implements a protected static Log method that handles sending messages to the Unity console with the appropriate severity level.
This method maps each Type value to the corresponding Unity logging call:
Info->Debug.LogWarning->Debug.LogWarningError->Debug.LogError
Summary Helper
The base class also provides a helper for generating consistent action summaries:
This prefixes the summary with the correct label for the selected log type, such as:
LogLog WarningLog Error
FSM Logging
Implements a protected FsmLog method to send messages to the FSM Log with the appropriate severity level.
This is only active in the Unity Editor.
At runtime builds, the method is excluded with Conditional("UNITY_EDITOR").
This lets logging actions write useful debugging information to the editor FSM log without affecting player builds.
Typical Pattern
Actions that inherit from BaseDebugLogAction usually follow this pattern:
- Build the output string in
Execute() - Call
Log(logType, output)to write to the Unity Console - Call
FsmLog(logType, output)to also write to the FSM Log in the editor - Use
GetLogSummary(...)inGetSummary()for a consistent action label
Example
DebugLog is a typical example:
using UnityEngine;
using JetBrains.Annotations;
namespace HutongGames.PlayMaker.Actions
{
[System.Serializable]
[PublicAPI]
[ActionCategory(Category.Debug)]
[ActionDescription("Print a message to the Unity Console and FSM Log.")]
public class DebugLog : BaseDebugLogAction
{
[Tooltip("Message Type.")]
public Type LogType;
[Delayed, HideLabel, OptionalField, Multiline(5), HasVariableNames]
[DefaultValue("")]
[Tooltip("Text to log to the Unity Console.")]
public StringVar Text;
public override void Execute()
{
var output = GetOutput();
Log(LogType, output);
FsmLog(LogType, output);
}
private string GetOutput() => Text.IsVariable
? DebugUtility.GetDebugString(Text.Variable)
: DebugLogTextFormatter.Format(Text.Value, Fsm?.Variables);
public override string GetSummary() => GetLogSummary(LogType, "{Text}");
}
}
With this setup, the base class handles the common logging behavior and summary formatting, while the derived action only needs to define what text should be logged.
When To Use It
Use BaseDebugLogAction when your action:
- writes messages to the Unity Console
- supports different log severities
- should also write to the FSM Log in the editor
- needs a consistent summary format for log actions
If the action is not actually logging anything, another base class is usually a better fit.