Skip to content

Commit

Permalink
Added a friendly name property to the Writer objects
Browse files Browse the repository at this point in the history
Resolves #29

Signed-off-by: jachguate <[email protected]>
  • Loading branch information
jachguate committed Feb 15, 2023
1 parent 95c6f04 commit 04c5fba
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/UjachLogMgr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ TjachLogWriter = class
function GetLogLevel(Index: TjachLogTopicIndex): TLogLevel;
procedure SetLogLevel(Index: TjachLogTopicIndex; const Value: TLogLevel);
procedure SetDebugVerbosityThreshold(const Value: Byte);
procedure SetFriendlyName(const Value: string);
protected
const WWMAX_LEN = 255;
var
FFriendlyName: string;
function WordWrap(const S: string; MaxLen: UInt16 = WWMAX_LEN): TStringDynArray; virtual;
public
constructor Create(ADefaultTopicLevel: TLogLevel = llAll); virtual;
Expand All @@ -157,6 +160,7 @@ TjachLogWriter = class
property Thread: TThread read FThread;
property LogLevel[Index: TjachLogTopicIndex]: TLogLevel read GetLogLevel write SetLogLevel;
property DebugVerbosityThreshold: Byte read FDebugVerbosityThreshold write SetDebugVerbosityThreshold;
property FriendlyName: string read FFriendlyName write SetFriendlyName;
end;

TjachLogWriterClass = class of TjachLogWriter;
Expand Down Expand Up @@ -541,6 +545,7 @@ constructor TjachLogWriter.Create;
FLock := TCriticalSection.Create;
for I := Low(FLogLevel) to High(FLogLevel) do
FLogLevel[I] := ADefaultTopicLevel;
FFriendlyName := Self.ClassName;
end;

destructor TjachLogWriter.Destroy;
Expand Down Expand Up @@ -575,6 +580,11 @@ procedure TjachLogWriter.SetDebugVerbosityThreshold(const Value: Byte);
FDebugVerbosityThreshold := Value;
end;

procedure TjachLogWriter.SetFriendlyName(const Value: string);
begin
FFriendlyName := Value;
end;

procedure TjachLogWriter.SetIsActive(const Value: Boolean);
begin
FIsActive := Value;
Expand Down
7 changes: 7 additions & 0 deletions src/ujachLogToConsole.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface
type
TjachLogToConsole = class(TjachLogWriter)
public
constructor Create(ADefaultTopicLevel: TLogLevel = llAll); override;
procedure Write(ATopic: TjachLogTopicIndex; ASeverity: TLogSeverity;
ADebugVerbosity: Byte; const S, AIndentSpaces: string;
const AThreadID: TThreadID; const ATimeStamp: TDateTime); override;
Expand All @@ -61,6 +62,12 @@ implementation

{ TjachLogToConsole }

constructor TjachLogToConsole.Create(ADefaultTopicLevel: TLogLevel);
begin
inherited;
FFriendlyName := 'Console';
end;

procedure TjachLogToConsole.Write(ATopic: TjachLogTopicIndex;
ASeverity: TLogSeverity; ADebugVerbosity: Byte; const S, AIndentSpaces: string;
const AThreadID: TThreadID; const ATimeStamp: TDateTime);
Expand Down
1 change: 1 addition & 0 deletions src/ujachLogToDisk.pas
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ procedure TjachLogToDisk.CloseLogChannel;
constructor TjachLogToDisk.Create(ADefaultTopicLevel: TLogLevel = llAll);
begin
inherited;
FFriendlyName := 'Disk';
FMaxFileSize := 20 * 1024 * 1024; //20MB
FMaxLineSize := 255;
FBasePath := GetDefaultBasePath;
Expand Down
1 change: 1 addition & 0 deletions src/ujachLogToFMXMemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ procedure TjachLogToFMXMemo.CloseLogChannel;
constructor TjachLogToFMXMemo.Create;
begin
inherited;
FFriendlyName := 'Screen';
FEntries := TThreadedQueue<IjachLogEntry>.Create(32768, 0, 0);
IsActive := False;
if GetIsMainThread then
Expand Down
1 change: 1 addition & 0 deletions src/ujachLogToSysLogIndyUDP.pas
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ procedure TjachLogToSysLogIndyUDP.CloseLogChannel;
constructor TjachLogToSysLogIndyUDP.Create;
begin
inherited;
FFriendlyName := 'SysLog';
IsActive := False;
FIdSysLog := TIdSysLog.Create(nil);
FIdSysLogMessage := TIdSysLogMessage.Create(nil);
Expand Down
1 change: 1 addition & 0 deletions src/ujachLogToVCLRichEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ procedure TjachLogToVCLRichEdit.CloseLogChannel;
constructor TjachLogToVCLRichEdit.Create;
begin
inherited;
FFriendlyName := 'Screen';
FEntries := TThreadedQueue<IjachLogEntry>.Create(32768, 0, 0);
IsActive := False;
if GetIsMainThread then
Expand Down

0 comments on commit 04c5fba

Please sign in to comment.