Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Developer accessible log
Mon, Apr 21 2014 11:06 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Can we have a developer accessible log like your current system log? I think the first 4 columns of your's would be adequate.

The reason for asking is that I'm needing to log things in a robust fashion so I don't want to use normal database operations in case its something I'm doing there that's screwing up and I like to do things with minimal overhead.

I'd like to write to the log from inside a main app, threads, and external dlls like word generator code. Any chance?

Off now to look for an interim solution.

Roy Lambert
Tue, Apr 22 2014 7:55 AMPermanent Link

Peter Evans

On 22/04/2014 1:06 AM, Roy Lambert wrote:
Roy,
Recently I have been using the logging code that comes with the
framework  tiOpf.
That code is in a Git Repository.
Look in the Core folder, say unit 'tiLog.pas', and associated ones.

The only drawback is it does put in some units. The positive is that it
is thread safe.

Regards,
  Peter Evans
Tue, Apr 22 2014 7:57 AMPermanent Link

Peter Evans

On 22/04/2014 9:55 PM, Peter Evans wrote:

>
> The only drawback is it does put in some units. The positive is that it
> is thread safe.

Meant to say "pull" instead of "put".
Tue, Apr 22 2014 8:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


Thanks, I'll have a look at it.

Roy Lambert
Thu, Apr 24 2014 2:19 AMPermanent Link

Peter Evans

Here is a simple logging unit.
The log gets created in the directory of the application.
The log has a fixed file name.

To use it make a call like :-
  gSTLog.Log('Hello');
No initialization is required.

Regards,
  Peter Evans

unit STLog;

interface

USES
  tiLog;

type

  TSTLog = class
  private

  public
    CONSTRUCTOR Create;
    DESTRUCTOR Destroy; OVERRIDE;

    Procedure Log(const AMessage : string;
                  const ASeverity : TtiLogSeverity = lsNormal);

  end ;

// A function with application wide visibility to surface the unit wide
// variable uSTLog
function gSTLog : TSTLog;

implementation

USES
  tiLogToFile,
  System.SysUtils;

var
  // Hold a single instance of our identifier factory
  uSTLog : TSTLog;

//------------------------------------------------------------------------------
function gSTLog : TSTLog;
begin
  if uSTLog = nil then begin
    GLog.RegisterLog(
                     TtiLogToFile.CreateWithFileName(
                       System.SysUtils.GetCurrentDir {FilePath},
                       'ST_Test_Log.txt' {FileName},
                       False {OverwriteOldFile}
                                                    )
                     );
    uSTLog := TSTLog.Create;
  end;
  result := uSTLog;
end;

CONSTRUCTOR TSTLog.Create;
BEGIN
  inherited Create;
  {Set up all the defaults}
  { }
END;{Create}

DESTRUCTOR TSTLog.Destroy;
BEGIN
  { }
  inherited Destroy; {must be last}
END;{Destroy}

Procedure TSTLog.Log(const AMessage : string;
                     const ASeverity : TtiLogSeverity = lsNormal);
begin
  GLog.Log(AMessage, ASeverity);
end;

initialization
  uSTLog := Nil;

finalization
  FreeAndNil(uSTLog);

end.
Thu, Apr 24 2014 2:50 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


Thanks

Roy Lambert
Image