Recent

Author Topic: Usage of Lazlogger  (Read 888 times)

superc

  • Sr. Member
  • ****
  • Posts: 250
Usage of Lazlogger
« on: July 04, 2024, 12:02:03 pm »
Hello,

I'm not understand how use Lazlogger works: I imported uses lazlogger  but now what I have to do? I can't figure out from the documentation which object to instantiate to define the output file....

Thanks in advance.

cdbc

  • Hero Member
  • *****
  • Posts: 1497
    • http://www.cdbc.dk
Re: Usage of Lazlogger
« Reply #1 on: July 04, 2024, 12:11:19 pm »
Hi
AFAIK you 'uses' LazLogger only in your main unit and then 'uses' LazLoggerBase in the other units you want to enable logging in.
Then it's a matter of using the methods of the base logger class...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

superc

  • Sr. Member
  • ****
  • Posts: 250
Re: Usage of Lazlogger
« Reply #2 on: July 04, 2024, 12:51:20 pm »
Thank you, I've moved unit LazLogger into main unit and LazLoggerBase in other unit, now I want set filenamepath of log for output file from code now what I can't understand is where I can set the log filename, because in LazLoggerBase can't find how to set the name... thanks in advance

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10235
  • Debugger - SynEdit - and more
    • wiki
Re: Usage of Lazlogger
« Reply #3 on: July 04, 2024, 12:54:18 pm »

superc

  • Sr. Member
  • ****
  • Posts: 250
Re: Usage of Lazlogger
« Reply #4 on: July 04, 2024, 04:30:19 pm »
https://wiki.freepascal.org/LazLogger
I report what interests me:

Quote
File
Debug output can also be written to file. The initialization code of the logging unit

checks your program's command line parameters for --debug-log=<file> (In Lazarus: Run / Run Parameters / Command line parameters). On finding this parameter, any subsequent debug output is sent to <file>.
The param name can be changed with DebugLogger.ParamForLogFileName:='--debug-log'; This property exists only if the unit LazLogger is used. (LazLoggerBase does not define this property)
If no '--debug-log' command line parameter has been given, it next checks if an operating system environment variable xxx_debuglog exists, where xxx is the program file name without extension. E.g. for Lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses the file specified in that environment variable as file to receive debug output.
Example: if you do:

set lazarus_debuglog=c:\lazarus\debug.txt
and run Lazarus, debug output will be written to c:\lazarus\debug.txt.

so if I wanted to set the log file, without going through run-parameter, should I define an environment variable?
I find this solution embarrassing to say the least
« Last Edit: July 04, 2024, 04:32:55 pm by superc »

cdbc

  • Hero Member
  • *****
  • Posts: 1497
    • http://www.cdbc.dk
Re: Usage of Lazlogger
« Reply #5 on: July 04, 2024, 05:31:00 pm »
Hi
Try this: "DebugLogger.LogName:= 'volapyk.log';" as early as possible.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018