Coverage report for Casbin.Core.Logger.Base.
Generated at 18/02/2019 12:10:19 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.
Statistics for Casbin.Core.Logger.Base.pas
| Number of lines covered | 18 |
| Number of lines with code gen | 18 |
| Line coverage | 100% |
| 1 | // Copyright 2018 by John Kouraklis and Contributors. All Rights Reserved. |
| 2 | // |
| 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 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | unit Casbin.Core.Logger.Base; |
| 15 | |
| 16 | interface |
| 17 | |
| 18 | uses |
| 19 | Casbin.Core.Base.Types, Casbin.Core.Logger.Types; |
| 20 | |
| 21 | type |
| 22 | {$REGION 'This is the base logger class. It does not do anything. You can expand the functionality by subclassing this one'} |
| 23 | /// <summary> |
| 24 | /// <para> |
| 25 | /// This is the base logger class. It does not do anything. |
| 26 | /// </para> |
| 27 | /// <para> |
| 28 | /// You can expand the functionality by subclassing this one |
| 29 | /// </para> |
| 30 | /// </summary> |
| 31 | {$ENDREGION} |
| 32 | TBaseLogger = class (TBaseInterfacedObject, ILogger) |
| 33 | private |
| 34 | fEnabled: Boolean; |
| 35 | {$REGION 'Interface'} |
| 36 | function getEnabled: Boolean; |
| 37 | function getLastLoggedMessage: string; |
| 38 | procedure setEnabled(const aValue: Boolean); |
| 39 | {$ENDREGION} |
| 40 | protected |
| 41 | fLastLoggedMessage: string; //PALOFF |
| 42 | public |
| 43 | {$REGION 'Interface'} |
| 44 | procedure log(const aMessage: string); virtual; |
| 45 | {$ENDREGION} |
| 46 | public |
| 47 | constructor Create; |
| 48 | end; |
| 49 | |
| 50 | implementation |
| 51 | |
| 52 | uses |
| 53 | System.SysUtils; |
| 54 | |
| 55 | constructor TBaseLogger.Create; |
| 56 | begin |
| 57 | inherited; |
| 58 | fEnabled:=True; |
| 59 | end; |
| 60 | |
| 61 | { TBaseLogger } |
| 62 | |
| 63 | function TBaseLogger.getEnabled: Boolean; |
| 64 | begin |
| 65 | result:=fEnabled; |
| 66 | end; |
| 67 | |
| 68 | function TBaseLogger.getLastLoggedMessage: string; |
| 69 | begin |
| 70 | Result:=fLastLoggedMessage; |
| 71 | end; |
| 72 | |
| 73 | procedure TBaseLogger.log(const aMessage: string); |
| 74 | begin |
| 75 | if not fEnabled then |
| 76 | Exit; |
| 77 | fLastLoggedMessage:=trim(aMessage); |
| 78 | end; |
| 79 | |
| 80 | procedure TBaseLogger.setEnabled(const aValue: Boolean); |
| 81 | begin |
| 82 | fEnabled:=aValue; |
| 83 | fLastLoggedMessage:=''; |
| 84 | end; |
| 85 | |
| 86 | end. |