ALogDecorater.cs 642 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. namespace Base
  2. {
  3. public abstract class ALogDecorater
  4. {
  5. protected const string SEP = " ";
  6. private int level;
  7. protected readonly ALogDecorater decorater;
  8. protected ALogDecorater(ALogDecorater decorater = null)
  9. {
  10. this.decorater = decorater;
  11. this.Level = 0;
  12. }
  13. protected int Level
  14. {
  15. get
  16. {
  17. return this.level;
  18. }
  19. set
  20. {
  21. this.level = value;
  22. if (this.decorater != null)
  23. {
  24. this.decorater.Level = value + 1;
  25. }
  26. }
  27. }
  28. public virtual string Decorate(string message)
  29. {
  30. if (this.decorater == null)
  31. {
  32. return message;
  33. }
  34. return this.decorater.Decorate(message);
  35. }
  36. }
  37. }