I wish to have a debug logger in a class that should be extended. Is there a way to do this without having to add the log entry on every derived class?
using System;
public abstract class Phase {
public virtual void Start() {
Console.Write("[LOG] Start");
}
/// <summary>
/// Returns true when finished.
/// </summary>
public virtual bool Update() {
Console.Write("[LOG] Update");
return true;
}
public virtual void End() {
Console.Write("[LOG] End");
}
}
public class PhaseMenu : Phase {
private byte _counter;
public override void Start() {
_counter = 0;
}
public override bool Update() {
_counter++;
if ( _counter > 100 ) {
return true;
}
return false;
}
public override void End() {
}
}
Desired outcome is to have the LOGs be written whenever PhaseMenu's methods are called. So that the methods aren't overriding but rather extending.