GithubHelp home page GithubHelp logo

exilon / quicklogger Goto Github PK

View Code? Open in Web Editor NEW
352.0 47.0 80.0 74.5 MB

Powerful and flexible library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).

License: Apache License 2.0

Pascal 67.02% C# 32.58% Dockerfile 0.40%
delphi redis console logger logging log telegram slack sql freepascal

quicklogger's People

Contributors

aurelienvelo avatar chicknsoup avatar dependabot[bot] avatar exilon avatar gasperz avatar hugorosariozs avatar jfudickar avatar jtone123 avatar mrcsms avatar pjrobin avatar turric4n avatar v0d01ey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quicklogger's Issues

Adding Custom Fields

Hello.
I'm using QuickLogger and GrayLog.
I can receive Error and Success messages.

I want to add a few custom fields.
Example: version, module, customer... etc.

I can send a message myself like this;
Logger.Succ('Currency Downloaded Successfuly.');
and I want to add these fields in auto-captured error messages...

Is there any way I can do this?

My config is below.

  with GlobalLogGrayLogProvider do
  begin
    URL := 'http://192.168.1.248:12202';
    LogLevel := LOG_DEBUG;
    MaxFailsToRestart := 5;
    MaxFailsToStop := 0;
    {$IFDEF DEBUG}
      Environment := 'DEBUG';
    {$ELSE}
      Environment := 'RELEASE';
    {$ENDIF}
    PlatformInfo := 'WinService';
    IncludedInfo := [iiAppName, iiHost, iiUserName, iiEnvironment, iiPlatform, iiOSVersion, iiExceptionInfo, iiExceptionStackTrace, iiThreadId, iiProcessId];
    ShortMessageAsEventType := False;
    Enabled := TRUE;
  end;
Logger.Succ('Currency Downloaded Successfuly.');

Error 401 when trying to create a database in InfluxDB

According to a similar issue reported for Grafana, sometimes it is necessary to include an Authorization token in the HTTP header during the POST for creating the database.
In my case, I was the owner of the organization and I created two tokens, one for common access (reading and writing to an existing database), and another for creating a database on-the-fly.
I couldn't create the database with my username and password.
There is a Post method for fHTTPClient ready to receive JSON pairs, but there is no token in the provider class.

Load/Save config, init from file

Unfortunately the method described in the readme does not work.
Logger.Providers has neither FromJson no LoadFromFile methods.

QuickLib.Inc error

Hi, there is a small typo in QuickLib.inc: you have "{$if CompilerVersion >= 33.0} " twice

GetIt package problem

Hi

I installed QuickLogger to Sydney 10.4.1/windows 32 and it looked ok but it looks like there is a problem.

I tried my first project with the logger but it does not seem to find some files.

I did:

uses
Quick.Logger,
Quick.Logger.Provider.Files,
Quick.Logger.Provider.Console;

and it could not find the files:

Quick.Logger.Intf,
Quick.JSON.Utils,
Quick.Json.Serializer,

etc.

It seems that they are not included in the package manager but a lot of c# code is there?

Sincerely, Edward

Linux 使用守护进程 本地日志不能写入

if fork()<>0 then
begin
exit;
end;

Logger.CustomTags['MYTAG2'] := FormatDateTime('YYYYMMDD', Now);
//
Logger.Providers.Add(GlobalLogFileProvider);
with GlobalLogFileProvider do
begin
FileName := './log/'+aLogName+FormatDateTime('YYYYMMDD', Now)+'.log';
LogLevel := LOG_TRACE;
TimePrecission := True;
MaxRotateFiles := 10;
MaxFileSizeInMB := 10;
DailyRotate:= True;
RotatedFilesPath := './log/Logs';
CompressRotatedFiles := False;
// CustomMsgOutput := True;
AppName:= 'TaskJob';
CustomFormatOutput := '[%{DATETIME}] [%{LEVEL}] : %{MESSAGE} [%{APPNAME}] [(%{MYTAG2})]';
CustomMsgOutput:= True;
Enabled := True;
end; //

不能写入本地日志, no find loginfo

Delphi 10.2.2 Linux x64

Hello!
Did I miss something?
Output without correct time:

----------------------------------------------------------------------
Application : Project1
Path        : /root/PAServer/scratch-dir/Tester-Linux64/Project1/
CPU cores   : 2
OS version  : Ubuntu 14.04.5 LTS #140~14.04.1-Ubuntu SMP Fri Feb 16 09:25:20 UTC 2018 (Version 4.4.0)
Started     : 04/15/2018 06:59:04 PM
----------------------------------------------------------------------
30-12-1899 00:00:00 [INFO] Test entry
30-12-1899 00:00:00 [WARN] Test number: 1

Simple test:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  Quick.Logger,
  Quick.Logger.Provider.Files,
  // Quick.Logger.Provider.Console,
  System.SysUtils;

begin
  try
    Logger.Providers.Add(GlobalLogFileProvider);
    with GlobalLogFileProvider do
    begin
      FileName := '.\Logger.log';
        DailyRotate := True;
        MaxFileSizeInMB := 20;
        LogLevel := LOG_ALL;
      Enabled := True;
    end;

//    Logger.Providers.Add(GlobalLogConsoleProvider);
//    with GlobalLogConsoleProvider do
//    begin
//      LogLevel := LOG_DEBUG;
//        ShowEventColors := True;
//        Enabled := True;
//    end;

    Log('Test entry', etInfo);
    Log('Test number: %d',[1], etWarning);

    Readln;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Exception in QuickLogger.Provider.Memory -> WriteLog if MaxSize > 0

Minor problem:
in procedure TLogMemoryProvider.WriteLog(cLogItem : TLogItem); you have
repeat fMemLog.Delete(0) until fMemLog.Count < fMaxSize;
this produce an exception when writing the first Log message.
Should be replaced with
while fMemLog.Count >= fMaxSize do fMemLog.Delete(0);

AutoFlush Bug

Hi,

In Quick.Logger.Provider.Files.pas line 257

is

//needs to flush if autoflush??
if not fAutoFlush then fLogWriter.Flush;

should be

//needs to flush if autoflush??
if fAutoFlush then fLogWriter.Flush;

Suggestion: WriteToStream -> Protected.

Hi there,
I was writing a new provider based on the Provider.Files. Provider.Files has a lot of valuable methods and data that can be reused but I noticed that a key part of it was made private so I cant use it.

WriteToStream.

Could it be made protected? (I did on my version but it will be nice if it is part of the core logger so my provider doesn't hurt what is there).

Thank you.

Does this work for an OSX Dylib? Because I can't get any output

According to the instructions, I am iniitialzing it with

Logger.Providers.Add(GlobalLogConsoleProvider);
with GlobalLogConsoleProvider do
begin
	LogLevel := LOG_ALL;
    ShowEventColors := True;
    Enabled := True;
end;
Log('Test entry',etInfo);
Log('Test number: %d',[1],etWarning);

It all compiles fine but nothing is ever sent to the console. Should this work? Am am don't something wrong?

Each log entry can be duplicated

I am using the library for a simple record of the execution time of some consecutive processes.

Using the file provider, the first time the method sequence is executed, the log record works correctly, but if the sequence is executed again, after the first sequence, the log record duplicates each entry.

I imagine it could be a registry buffer bug?

Summarizing

Using Log('Start: 16:53:03.239', etInfo) for each line.
First round:
Processing...
Start: 16:53:03.239
End: 00:00:00.0000

Second round:
Processing...
Processing...
Start: 16:53:04.239
Start: 16:53:04.239
End: 00:00:00.0000
End: 00:00:00.0000

How to add custom tags when sending to sentry.io?

My code is as the following but it seems that sentry.io doesn't receive the 'version' tag:

procedure TForm3.FormCreate(Sender: TObject);
begin
  Logger.Providers.Add(GlobalLogSentryProvider);
  Logger.CustomTags.Add('version', '1.0.1.23');

  GlobalLogSentryProvider.DSNKey := 'https://[email protected]/12345';
  GlobalLogSentryProvider.LogLevel := LOG_ALL;
  GlobalLogSentryProvider.MaxFailsToRestart := 5;
  GlobalLogSentryProvider.MaxFailsToStop := 0;
  GlobalLogSentryProvider.Environment := 'Production';
  GlobalLogSentryProvider.PlatformInfo := 'Desktop';
  GlobalLogSentryProvider.IncludedInfo := [iiAppName,iiEnvironment,iiPlatform,iiOSVersion,iiUserName];

  GlobalLogSentryProvider.Enabled := True;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
  Logger.Info('this is an info B');
  Logger.Error('this is an error B!');
end;

Delphi 11 compilation warnings

Hi,

QuickLogger installed from GetIt during compilation on Delphi 11 has this kind of warnings:

[dcc32 Warning] Quick.JSON.Utils.pas(102): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit.
[dcc32 Warning] Quick.JSON.Utils.pas(116): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit.
[dcc32 Warning] Quick.Json.Serializer.pas(466): W1035 Return value of function 'TRTTIJson.DeserializeStream' might be undefined
[dcc32 Warning] Quick.Json.Serializer.pas(590): W1057 Implicit string cast from 'TSymbolName' to 'string'
[dcc32 Warning] Quick.Json.Serializer.pas(1301): W1057 Implicit string cast from 'TSymbolName' to 'string'
[dcc32 Hint] Quick.Json.Serializer.pas(1456): H2164 Variable 'json' is declared but never used in 'TRTTIJson.SerializeStream'
[dcc32 Hint] Quick.Json.Serializer.pas(134): H2219 Private symbol 'GetValue' declared but never used
[dcc32 Hint] Quick.Json.Serializer.pas(136): H2219 Private symbol 'GetPropertyValue' declared but never used
[dcc32 Hint] Quick.Json.Serializer.pas(142): H2219 Private symbol 'SetPropertyValue' declared but never used
[dcc32 Hint] Quick.Json.Serializer.pas(205): H2219 Private symbol 'SetUseNullStringsAsEmpty' declared but never used
[dcc32 Warning] Quick.Threads.pas(2444): W1035 Return value of function 'TBackgroundWorkers.WaitAndRetry' might be undefined
[dcc32 Warning] Quick.Threads.pas(2449): W1035 Return value of function 'TBackgroundWorkers.WaitAndRetry' might be undefined
[dcc32 Warning] Quick.Threads.pas(2454): W1035 Return value of function 'TBackgroundWorkers.WaitAndRetry' might be undefined
[dcc32 Warning] Quick.Threads.pas(2459): W1035 Return value of function 'TBackgroundWorkers.WaitAndRetryForever' might be undefined
[dcc32 Warning] Quick.Threads.pas(2464): W1035 Return value of function 'TBackgroundWorkers.WaitAndRetryForever' might be undefined
[dcc32 Hint] Quick.Threads.pas(603): H2219 Private symbol 'fMaxRetries' declared but never used

Access Violation

Hi,
I try to use the FileProvider Quicklogger on a windows machine. But i get after some minutes an error and my application crached / hanged.

I use the logging from many different Threads. I have a mutex around the Log() function.
It seems that the problem come after large logs. Maybe a problem in the queue handle? Multiple access?

Have you an idea what i can do?

My Initialization:

Logger.Providers.Add(GlobalLogFileProvider);
// Configure provider options
with GlobalLogFileProvider do
begin
filename := '.\Logs_Planning\Logger.log';
DailyRotate := True;
MaxFileSizeInMB := 200;
LogLevel := [etHeader, etError, etInfo, etSuccess, etWarning];
TimePrecission := false;
MaxFailsToRestart := 2;
MaxFailsToStop := 10;
CustomMsgOutput := false;
UsesQueue := True;
Enabled := True;
end;

My use:

procedure LogQuickMessage(Msg: String; msgType: TCodeSiteTypes = cslDefault; filename: String = '');
begin
try
FMutex.Acquire;
Log(Msg, CastCStoETEnum(msgType));
finally
FMutex.Release;
end;
end;

Best Regards
Johann

Inconsistent declaration of constant LOG_ALL

In Quick.Logger you have
LOG_ALL = [etHeader,etInfo,etSuccess,etDone,etWarning,etError,etCritical,etException,etCustom1,etCustom2]
In Quick.Commons
LOG_ALL = [etInfo, etSuccess, etWarning, etError, etDebug, etDone, etTrace, etCritical, etException];

Log files not being written when called from a Windows Service.

Hi there,
I'm using Delphi Rio 10.3.2. I'm moving all my Windows Services to use QuickLogger but I'm having problems with it.

When the logger is executed from a normal application (console or GUI) log files are written properly, Rotated Logs directory is created, etc, etc. But when executed as a service log files are not being written. I tried playing with permissions with no avail, is there something I might be missing? or some consideration I should have? I use Windows 2016 for service testing and Windows 10 when testing it as a console.

Thank you in advance.

Setting GlobalLogFileProvider.FileName after enabled causes AV error later

Hi,
I tried to use this logger the very first time and encountered some minor issues.
It is very easy to avoid but I just want to report what happened. Thank you.

Delphi 11.1
FMX.MultiLogger project

procedure TfrmMain.FormCreate(Sender: TObject);
begin
GlobalLogFileProvider.LogLevel := LOG_ALL;
GlobalLogFileProvider.Enabled := True;
// 1. BTW, can not do this: GlobalLogFileProvider.FormatSettings.ShortDateFormat := 'yyyy-mm-dd hh:nn:ss';
// 2. Setting GlobalLogFileProvider.FileName after enabled causes AV error later
GlobalLogFileProvider.FileName := '.\abc.log';
GlobalLogFileProvider.IncludedInfo := GlobalLogFileProvider.IncludedInfo + [iiThreadId];
...

Suggestion: Line format

Hi,

The suggestion:
Allow to specify a line format. For example, if you set something like:

LogProvider.LineFormat := '%{DATE} %{TIME} %{LEVEL} - ThreadId: %{THREADID} - PId: %{PID} - %{MSG}';

Where %{} is a way to access pre-defined built in output primitives from quicklogger. It will allow to customize the output to match other loggers if there is a need to standarized on a log format. Also if there are Logstash grok filters its easier to just follow an existing filter than customize the format to a specific one.

This can be later on improved by allowing to enter other pre-defined fixed values before the logger is initialize. For example:

QuickLoggerOutPutDictionary["Module"] := 'Finance';
QuickLoggerOutPutDictionary["KEY"]:= 'FIN';

So you can extend the line format to support things like:

LineFormat := '%{DATE} %{TIME} %{LEVEL} %{MODULE} %{KEY} - ThreadId: %{THREADID} - PId: %{PID} - %{MSG}';

Or you can simply implement the dictionary first and add by default the existing output primitives.

This is just a suggestion. I will probably ended up patching quicklogger LogItemToLine to achieve this behaviour but it will be great if something like this comes built into QuickLogger.

Thank you in advance for your great work.

code could not be compiled (Delphi XE7)

Hello,

there are 2 problems:

  1. dependencies to Quick.Lib, they are not mentioned anywhere
    ok, this problem could be solved by copying particular files to the destination folder from the Quick.Lib project
    2 JSONBool type is not defined, caused error in Quick.Json.Serializer

EinvalidPointer exception with GlobalLogEventLogProvider on close

Hi,

I've done a simple form with just QuickLogger inside

uses
[...]
    ,Quick.Logger,Quick.Logger.Provider.EventLog;

[...]

procedure TForm2.FormCreate(Sender: TObject);
begin
    Logger.Providers.Add(GlobalLogEventLogProvider);
    GlobalLogEventLogProvider.Enabled:=True;
    Log('Hello world', etInfo);
end;

All works perfectly, but when I close this windows, I've got an exception (EinvalidPointer) with the message "Opération de pointeur incorrecte" (Invalid Pointer Operation)

It works without problems when I use GlobalLogFileProvider.

Is a log file viewer planned?

One of the best features that I'm missing from SmartInspect is the log file viewer...curious if there are plans to add a viewer here.

Logger with console (log type)

Hello, exilon~

1298 line in Quick.Logger

procedure TLogger.Trace(const cMsg: string);
begin
Self.Add(cMsg,TEventType.etDebug);
end;

it's should be etTract.. isn't it?

and, in log text in linux console with color.
it's not working just except first line.
first line is showing color is well done.
but, second line with color text include like this.
;97m20-11-2019 08:46:28.994 [INFO] Blah, Blah...

I'll try change TextBackground procedure in Quick.Console
{$IF DEFINED(DELPHILINUX) OR DEFINED(MACOS)}
write(AEC,0,';',Color+10*10);
{$ELSE}
-->
{$IF DEFINED(DELPHILINUX) OR DEFINED(MACOS)}
write(AEC,0,'m');
{$ELSE}

it's working well. but, i think this is not correct way~.

Thank you anyway~.

How to capture application exceptions?

Hello! Can you explain in more details how to capture application exceptions (ex. Access Violation)?
I added Quick.Logger.ExceptionHook, Quick.Logger.RuntimeErrorHook, Quick.Logger.UnhandledExceptionHook to uses clause,
but application exceptions don't writed to log file (use only GlobalLogFileProvider).

Logger raise exception in FMX (Android 64, MacOS)

Hello,

latest version of QuickLogger raise exception in FMX (Android 64 bit, MacOS)
exception is "Range Check Error"

  • cause
    TLogger.EnQueueItem(cLogItem: TLogItem)
    begin
    ...
    cLogItem.ThreadId := TThread.CurrentThread.ThreadId; <---- Here. (line no : 1409)
    ...
    end;

because,
ThreadId defined in System.pas
{$IF Defined(MSWINDOWS)}
TThreadID = LongWord;
{$ENDIF}
{$IFDEF POSIX}
TThreadID = NativeUInt;
{$ENDIF}

like this.
but, in TLogItem.ThreadId is DWORD. invalid type. UInt32 and UInt64.

FileLogger doesn't handle concurrency

Just start the demo twice. The second instance will crash.
You should either use a unique file name (GUID or ProcessID) during logging to avoid collisions or you have to invent some clever mechanism to avoid two instances to log into the same file. I'd recommend one file per instance/per run. Keep the last 10-20 logs (configurable)
After logging is done, you can rename the log files from the different instances to your liking. Use a mutex or whatever to prevent name collisions while doing so.

Suggestion: UTC

Hi

Just like there is for json, it will be good if there is way to set the logger to use UTC by default. Extremely good when deploying on multiple locations with different timezones.

Range Error when using CustomFormatOutput

No issue here, but to report a strange behaviour.

So I decided to update to the latest version of quick logger. Once I did it I noticed that I started to get a Range Error when using customformatoutputs. I didnt know what was causing it so I basically decided to just ignore the error and let it continue.

All good until I realized that it was not logging anything. I created a separate sample and it ran without trouble. I went crazy, spent hours and hours going at it, I debug it all the way to the loop:

Result := '';
idx := 1;
st := 0;
et := 0;
while st < fCustomFormatOutput.Length - 1 do
begin
if (fCustomFormatOutput[st] = '%') and (fCustomFormatOutput[st+1] = '{') then // <- ERROR here
begin

I'll step in and noticed that all indexes are fine, but for some reason it will throw that range error. I tried replacing the LogItemToFormat with the unused LogItemToFormat2 (its not called by anyone even if the version is over delphixe7) which didnt get the error but will get stock on certain moments so probably that's why its not used.

Finally I decided to replace .Length with the standard Length(fCustomFormatOutPut) just in case something was causing trouble with the string helper class and surprise, it started to work again.

So, for complex projects if you are using customOutPutformats and suddenly you start experiencing issues. Keep this one in mind.

No idea what other unit, project, compiler improvement is causing trouble with the helper but it did.

Issue within a library

Hi! Before anything, congrats on such a versatile logging library!

I have been struggling to encapsulate logging habilities for our win32 apps, but only when they are executed on Windows 7 or Windows server 2008 r2. If I run the code on Windows 10 or Windows Server 2016 or 2019, it works like a charm.

The problem seems to be related to thread handling inside a DLL.

I isolated the problem to the bare minimum, i'll attach the code and be grateful if anyone can give me a hand.

dll.zip

in Linux console application

i used in CentOS 7.x with QuickLogger. (Thank you very much~ it's so much useful library~)

  • (Delphi 10.3.2, QuickLogger and QuickLib from GetIt Manager - 1.8 i think..)

Logger's writing in file normally in nomal process.
but after fork not working.

i used like this.

var
vPid : pid_t;

begin
vPid := fork;
if vPid > 0 then
begin
// Parent
Exit;
end
else if vPid = 0 then
begin
// Fork process
end
else if vPid = -1 then
begin
// fork Error
Writeln('Fork error [' + errno.ToString + ']');
Exit;
end;

Logger.Providers.Add(GlobalLogFileProvider);
with GlobalLogFileProvider do
begin
  DailyRotate                 := True;
  LogLevel                    := LOG_DEBUG;
  Enabled                     := True;
  TimePrecission              := True;
end;

Logger.Providers.Add(GlobalLogConsoleProvider);
with GlobalLogConsoleProvider do
begin
  LogLevel                    := LOG_ALL;
  ShowEventColors             := True;
  ShowTimeStamp               := True;
  TimePrecission              := True;
  Enabled                     := True;
end;

Logger.Info('log Execute');
Logger.Trace('log Execute');
Logger.Error('log Execute');

Logger.info, Trace, Error --> Not Working.

Using logging in COM dll hangs when application is closed

Hello all,

I'm new here and landed here searching a solution for my problem.
I use the quick library and logger already in standard VCL programs with no problems at all.

Now my colleague and I are building a plugin for Outlook and Word.
For this we are using the components of add-in express.
So we're building a COM plugin for local instance of office.
The problem is when closing Word, It hangs.
In outlook this isn't a problem, so just word.

Debugging it I found the point it stops responding.
In Quick,Logger.pas at line 1315:

  fThreadProviderLog.Terminate;
  fThreadProviderLog.WaitFor;
  fThreadProviderLog.Free;
  //if Assigned(fProviders) then fProviders.Free;
  FreeAndNil( fProviders );
  fCustomTags := nil;
  FreeAndNil( fLogQueue ); 

The .WaitFor is never returning...
I also had a breakpoint in the thread that has to stop, the while loop is ended correctly.
So it seems the thread is terminatied after the calling of .Terminate method.

Kind regards,

Jan

Using QuickLogger in a multi threaded windows service.

I'm running a windows service with dynamically created custom thread objects. When in the debug build the logging works as expected by outputting to the a debug console however when the service is running as normal however only the header seems to get added to the log file and nothing else. The header essentially is the only thing that gets added into the same log file over and over.

Is there a way I should be running the logger in the a multi threaded windows service?

Logger settings in the dpr:

{$IFDEF DEBUG}
  try
    // Setup Quick Logger
    Logger.Providers.Add(GlobalLogConsoleProvider);
    with GlobalLogConsoleProvider do
    begin
      LogLevel := LOG_DEBUG;
      ShowEventColors := True;
      Enabled := True;
    end;

    // In debug mode the service acts as a console application.
    Log('TeraokaCheckWeigher DEBUG mode. Press enter to exit.', etInfo);
    TeraokaCheckWeigher := TTeraokaCheckWeigher.Create(nil);

    var
      dummy: Boolean;
    TeraokaCheckWeigher.ServiceStart(TeraokaCheckWeigher, dummy);

    ReadLn;

    // On exit, destroy the service object.
    FreeAndNil(TeraokaCheckWeigher);
  except
    on E: Exception do
    begin
      Log(E.ClassName + ': ' + E.Message, etException);
      Log('Press enter to exit.', etInfo);
      ReadLn;
    end;
  end;
{$ELSE}
  // Setup Quick Logger
  Logger.Providers.Add(GlobalLogFileProvider);
  with GlobalLogFileProvider do
  begin
    FileName := '.\Logger.log';
    DailyRotate := False;
    MaxFileSizeInMB := 20;
    LogLevel := LOG_DEBUG;
    Enabled := True;
  end;

  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;

  Application.CreateForm(TTeraokaCheckWeigher, TeraokaCheckWeigher);
  Application.Run;
{$ENDIF}

logScreenshot

Question. Process and Thread Id.

Hi there,

Fantastic job with your Logger. I'm trying to push your work around the community, very well done.

I have a question, I'm certain that you had lots of experience with existing loggers so I'm wondering why did you left out the current thread and process id from the default per line output.

These are essential on service/backend/multithreaded applications. We could add CurrentThread.ThreadId, etc on every output but it seems to be one of those basic things that should be included, what do you think?

Thank you in advance and thank you for your work.

Runtime Error 217 when using GlobalLogEventLogProvider in VCL

Hi,

first of all, thanks for
that great logging Tool.
I have tried to use that logging tool inside an VCL Applikation (64bit).
After adding GlobalLogEventLogProvider to the Logger and Close the Applikation I get error Message Runtime Error 217.

I can't really get why this happen.
Here is my demo App for reproduction.

LoggerDemo.zip

Delphi Version is Rad Studio 10.4.1.

I also testet it by adding the EventLog Provider to FMX Example.
There was no Message after closing but when I trigger to Log in ERROR mode, I also get a follow message inside the Windows Log. EventID 1000 Source Application Error. Seams something crashes the EventLogLogger.

Thats the Code I added in the FMX Example:

  GlobalLogEventLogProvider.LogLevel := LOG_ALL;
  GlobalLogEventLogProvider.Enabled  := True;
  GlobalLogEventLogProvider.Source   := 'Multilogger';
  Logger.Providers.Add(GlobalLogEventLogProvider);

Thanks.

Adding a QuickLogger to the USES section of the DLL causes to application to hang

Delphi 10.4

I am trying to add a file logger to my simple DLL application:

uses
  System.SysUtils,
  System.Classes,
{$IFDEF VER340}
  Quick.Logger,
  Quick.Logger.Provider.Files
{$ENDIF}
    ;

function FieldOfExperiments(): longint; stdcall;
begin
  Result := 0;
  try
  except
    on E: Exception do
  end;
end;

exports
    FieldOfExperiments;
{$R *.res}
begin
end.

When the main application attempts to load the DLL, the application gets unresponsive and hangs:

image

Any ideas? Did I miss something?

Thanks
Vitaly

Logger weird action in Linux

Hi, exilon.

I tested in CentOS with Quick.Logger.
Perfect working with "Debug" binary.
But, "Release" is raise exception.
I tried GlobalLogFileProvider fork and without fork.
it's makes trouble.
from SystemInfo.UserName.

if iiUserName in IncludedInfo then WriteToStream(Format('Username : %s',[Trim(SystemInfo.UserName)])); <-- this is raise exception. (Access violation...)

i'll try temporary way like this. (in Quick.SysInfo)

fUserName := String.Copy(GetLoggedUserName);
fUserName := Copy(fUserName, 1, Length(Trim(fUserName)));

just one line add.
than, working well. (Wrinteln is working too... :< )
i don't know why...
something in weird working pointer with "Release" build mode, i think.

thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.