Beginner in TMSLoggin

Hi !!!
I want make the log in a html file.
For this, I´m trying:

First try:
TMSLogger.RegisterOutputHandler(TTMSLoggerHTMLOutputHandler.Create('C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html'));

Second try:
TMSLogger.RegisterOutputHandlerClass(C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html']);

There is no error in compillation, but when I´ll to register a log with the command:
"TMSLogger.Info('Test')" raises a error:

"Cannot create file
"C:\Clientes\TMSLoggintest\Win32\Debug"

But, if I execute this:
ShowMessage(TTMSLoggerHTMLOutputHandler(Handler).FileName), the file is there

Thanks.

You can use it this way:

TMSLogger.RegisterManagedOutputHandler(TTMSLoggerHTMLOutputHandler.Create('C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html', 'C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.js'));

or this way:

TMSLogger.RegisterOutputHandlerClass(TTMSLoggerHTMLOutputHandler, ['C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html', 'C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.js']);

Hi. It´s doesn´t works.
The error
'Cannot Create File "C:\Clientes\TMSLoggintest\Win32\Debug\C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.js"

The project code is below:

implementation

uses
TMSLoggingCore, Bcl.TMSLogging, TMSLogging, TMSLoggingHTMLOutputHandler;

procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
begin
s := 'Hello World !';
TMSLogger.Info(s);
TMSLogger.Error(s);
TMSLogger.Warning(s);
TMSLogger.Trace(s);
TMSLogger.Debug(s);

end;

procedure TForm1.FormCreate(Sender: TObject);
var cCaminho:String;
begin

cCaminho := ExtractFilePath(ParamStr(0));

RegisterTMSLogger;
TMSLogger.RegisterManagedOutputHandler(TTMSLoggerHTMLOutputHandler.Create(cCaminho+\TMSLog.html',
cCaminho+\TMSLog.js'));

// TMSLogger.RegisterOutputHandlerClass(TTMSLoggerHTMLOutputHandler, ['C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html', 'C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.js']);

end;

Thanks.

I'm sorry, my mistake. The second parameter must only contain the .js file name, without path:

TMSLogger.RegisterOutputHandlerClass(TTMSLoggerHTMLOutputHandler, ['C:\Clientes\TMSLoggintest\Win32\Debug\TMSLog.html', 'TMSLog.js']);

No problem!
Now, works fine!
Thank you!

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.