Recent

Author Topic: [SOLVED] fpweb problems writing to syslog  (Read 4459 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
[SOLVED] fpweb problems writing to syslog
« on: February 16, 2013, 12:42:04 pm »
fpweb/cgi newbie here.

Server: Apache2 on Debian x64 Linux, using fpc 2.6.0 (alternatively FPC trunk).

I'm working on an fpweb cgi application to scan documents. Later on, I will build a Lazarus client that communicates using json with the cgi application.

I currently have the cgi application and a command line server application sharing common code.

I'm running into problems with the cgi app getting stuff from my database (on the server: tigerserver --list or the TFPWebModule1.listRequest in the tigercgi application): works fine on the server but got a rude Access violation. Suspect the db connection is not set up properly.

Decided to add some logging; used TEventLog.
Unfortunately, once again, the command line server logs nicely to /var/log/syslog; no log output from the cgi.
Should I fiddle with permissions (allow the www-data user to log to syslog or something)

Is there something I'm missing?

I'd be happy to post the code but don't know where the problem lies. If you want to have a look, you can find the tagged revision that shows my problems:
http://bitbucket.org/reiniero/papertiger/src/?at=lazforumquestion
... or download a zip:
https://bitbucket.org/reiniero/papertiger/downloads/tigerserver_20130216_forumquestion.zip

Any hints/tips/suggestions gratefully received.

Edit: clarification
« Last Edit: February 18, 2013, 12:48:06 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: fpweb problems writing to syslog
« Reply #1 on: February 16, 2013, 01:40:09 pm »
Just tried logging to syslog as www-data with the logger program. Works fine, so doesn't seem to be a permissions issue?!?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: fpweb problems writing to syslog
« Reply #2 on: February 16, 2013, 02:13:46 pm »
... and using the firebird isql-fb tool under www-data to connect to the server database works fine, as well.

Going to have a look at
http://www.hu.freepascal.org/lists/fpc-pascal/2011-October/030752.html
to see if I can use that...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: fpweb problems writing to syslog
« Reply #3 on: February 16, 2013, 02:51:01 pm »
Going to respond more to myself than a certain parallel compression library writer, but... in case anybody wants to chip in & in case this is useful for posterity:

1. The debugger unit in that post seems to work: I can use ddd/gdb to break into the cgi application
2. I used a direct call to syslog to try if logging worked (thanks Ludo!) - and it did. I now suspect my own log unit - perhaps it's creating multiple instances of TLogger:
Code: [Select]
...
var
  TigerLog: TLogger; //Created by unit initialization so available for every referencing unit
...
initialization
begin
  TigerLog:=TLogger.Create;
end;

finalization
begin
  TigerLog.Free;
end;

as the unit is included both in the db unit and the core unit... but that can't be it, can it? Surely the unit would be loaded in only once!?!?

Perhaps time to break this program up into a simple demo program that tests logging ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [SOLVED] fpweb problems writing to syslog
« Reply #4 on: February 18, 2013, 12:49:18 pm »
Final reply: fixed it ;)

Turns out I wrote a constructor and destructor for the webmodule and put my logging etc object creation/freeing there.
Doesn't work; they never get called. Instead used the OnCreate/OnDestroy events and it works.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018