Changeset 251 for Common


Ignore:
Timestamp:
Jun 13, 2011, 8:21:12 AM (13 years ago)
Author:
george
Message:
  • Modified: DebugLog transformed to component.
  • Fixed: String compare for template generics.
Location:
Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Common/Common.lpk

    r249 r251  
    66    <Author Value="Chronos (robie@centrum.cz)"/>
    77    <CompilerOptions>
    8       <Version Value="9"/>
     8      <Version Value="10"/>
    99      <PathDelim Value="\"/>
    1010      <SearchPaths>
     
    2929      <Item3>
    3030        <Filename Value="UDebugLog.pas"/>
     31        <HasRegisterProc Value="True"/>
    3132        <UnitName Value="UDebugLog"/>
    3233      </Item3>
  • Common/Common.pas

    r230 r251  
    88
    99uses
    10     StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI,
    11   UThreading, LazarusPackageIntf;
     10  StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading,
     11  LazarusPackageIntf;
    1212
    1313implementation
     
    1515procedure Register;
    1616begin
     17  RegisterUnit('UDebugLog', @UDebugLog.Register);
    1718end;
    1819
  • Common/UDebugLog.pas

    r250 r251  
    2424  private
    2525    FFileName: string;
     26    FMaxCount: Integer;
    2627    FOnNewItem: TNewItemEvent;
     28    FWriteToFileEnable: Boolean;
     29    procedure SetMaxCount(const AValue: Integer);
    2730  public
    28     WriteToFileEnable: Boolean;
    2931    Items: TThreadList;
    30     MaxCount: Integer;
    3132    procedure Add(Group: string; Text: string);
    3233    procedure WriteToFile(Text: string);
    33     property OnNewItem: TNewItemEvent read FOnNewItem write FOnNewItem;
    3434    constructor Create(AOwner: TComponent); override;
    3535    destructor Destroy; override;
    3636  published
     37    property WriteToFileEnable: Boolean read FWriteToFileEnable
     38      write FWriteToFileEnable;
    3739    property FileName: string read FFileName write FFileName;
     40    property MaxCount: Integer read FMaxCount write SetMaxCount;
     41    property OnNewItem: TNewItemEvent read FOnNewItem write FOnNewItem;
    3842  end;
    3943
    40 var
    41   DebugLog: TDebugLog;
     44procedure Register;
    4245
    4346implementation
    4447
     48procedure Register;
     49begin
     50  RegisterComponents('Common', [TDebugLog]);
     51end;
     52
    4553{ TDebugLog }
     54
     55procedure TDebugLog.SetMaxCount(const AValue: Integer);
     56var
     57  List: TList;
     58  I: Integer;
     59begin
     60  if FMaxCount = AValue then Exit;
     61  FMaxCount := AValue;
     62  List := Items.LockList;
     63  if List.Count > 0 then begin
     64    for I := AValue to List.Count - 1 do
     65      TDebugLogItem(List[I]).Free;
     66    List.Count := AValue;
     67  end;
     68  Items.UnlockList;
     69end;
    4670
    4771procedure TDebugLog.Add(Group: string; Text: string);
Note: See TracChangeset for help on using the changeset viewer.