TSimpleLayoutUnit.pas 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {
  2. Copyright 2005-2006 Log4Delphi Project
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. }
  13. {*----------------------------------------------------------------------------
  14. Contains the TSimpleLayout class.
  15. @version 0.5
  16. @author <a href="mailto:tcmiller@users.sourceforge.net">Trevor Miller</a>
  17. ----------------------------------------------------------------------------}
  18. unit TSimpleLayoutUnit;
  19. {$ifdef fpc}
  20. {$mode objfpc}
  21. {$h+}
  22. {$endif}
  23. interface
  24. uses
  25. TLayoutUnit, TLoggingEventUnit;
  26. type
  27. {*----------------------------------------------------------------------------
  28. SimpleLayout consists of the level of the log statement, followed by
  29. " - " and then the log message itself
  30. ----------------------------------------------------------------------------}
  31. TSimpleLayout = class (TLayout)
  32. private
  33. public
  34. function Format(AEvent : TLoggingEvent) : String; Override;
  35. end;
  36. implementation
  37. {*----------------------------------------------------------------------------
  38. Returns the log statement in a format consisting of the level, followed by
  39. " - " and then the message.
  40. @return The event formatted as a string
  41. ----------------------------------------------------------------------------}
  42. function TSimpleLayout.Format(AEvent : TLoggingEvent) : String;
  43. begin
  44. Result := AEvent.GetLevel.ToString + ' - ' + AEvent.GetMessage;
  45. end;
  46. end.