[os-libsynthesis] unified log file
Hello! My goal since switching to the Synthesis engine was to have one single log file again. There are other ideas for logging improvements, but the single log is the most important one: http://bugzilla.moblin.org/show_bug.cgi?id=3474 I've been dragging my feet a bit with it and I knew it would be kind of complicated, but now I have something which works. Beware, I didn't say it is nice ;-} It's also not final yet, but if possible, I'd like to get it done this week. I've pushed the code into the moblin.org "logging" branch of libsynthesis and SyncEvolution. Lukas, Beat, can you have a look at the code and tell me whether this is okay in principle and what might have to be changed to make it suitable for upstream? The main issues I see are: * had to use a global variable to pass information (TSyncAppBase::fGlobalAppLoggerP); ideally I'd pass the handle for the first engine (with the active logger) to the creator of the second engine (the one with the datastores) * can only log plain text via DB_DebugPuts_Func(); I'd like to include more information (severity level, source file/line) -- Best Regards, Patrick Ohly The content of this message is my personal opinion only and although I am an employee of Intel, the statements I make here in no way represent Intel's position on the issue, nor am I authorized to speak on behalf of Intel on this matter. ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
Hello Patrick, Before going into details, i.e. reviewing the patch I'd like to make sure I understand what is the goal: - you want a single log file for ALL logging, which means: - both global and session log of libsynthesis (including messages generated by the DB plugins) - PLUS messages generated by your application Right? I don't see why you need two engines for that. You can initialize the same engine twice, once at the beginning with basically only the log options, and a second time when your generated config stream is ready. Within the engine, you need: - a new flag to have the session logger redirect its output to the global logger, and also forwarding the flag to the global logger such that it won't overwrite the beginning of the log. Maybe some changes are needed to prevent re-instantiation of the global logger at the second init, I'll have to check that. - a way to send debug message from the outside (the app) into the global log. Luckily, these already exist (Beat uses them exactly this way in his test suite). See DB_DebugPuts, DB_DebugBlock, DB_DebugEndBlock and DB_DebugEndThread entries in the UI_Call_In record, or the ready-to-use wrappers for these in SDK_utils (DEBUG_xxx). Just let me know if your goal is something entirely different I haven't understood so far. But if I'm correct, I think we have do a much less invasive solution - and especially can avoid EVIL globals :-) Best Regards, Lukas Zeller On Jun 30, 2009, at 20:04 , Patrick Ohly wrote: Hello! My goal since switching to the Synthesis engine was to have one single log file again. There are other ideas for logging improvements, but the single log is the most important one: http://bugzilla.moblin.org/show_bug.cgi?id=3474 I've been dragging my feet a bit with it and I knew it would be kind of complicated, but now I have something which works. Beware, I didn't say it is nice ;-} It's also not final yet, but if possible, I'd like to get it done this week. I've pushed the code into the moblin.org "logging" branch of libsynthesis and SyncEvolution. Lukas, Beat, can you have a look at the code and tell me whether this is okay in principle and what might have to be changed to make it suitable for upstream? The main issues I see are: * had to use a global variable to pass information (TSyncAppBase::fGlobalAppLoggerP); ideally I'd pass the handle for the first engine (with the active logger) to the creator of the second engine (the one with the datastores) * can only log plain text via DB_DebugPuts_Func(); I'd like to include more information (severity level, source file/line) -- Best Regards, Patrick Ohly The content of this message is my personal opinion only and although I am an employee of Intel, the statements I make here in no way represent Intel's position on the issue, nor am I authorized to speak on behalf of Intel on this matter. ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis Lukas Zeller (l...@synthesis.ch) - Synthesis AG, SyncML Solutions & Sustainable Software Concepts i...@synthesis.ch, http://www.synthesis.ch ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
On Wed, 2009-07-01 at 08:19 -0700, Lukas Zeller wrote: > Hello Patrick, > > Before going into details, i.e. reviewing the patch I'd like to make > sure I understand what is the goal: > > - you want a single log file for ALL logging, which means: >- both global and session log of libsynthesis (including messages > generated by the DB plugins) >- PLUS messages generated by your application > > Right? Right. > I don't see why you need two engines for that. You can initialize the > same engine twice, once at the beginning with basically only the log > options, and a second time when your generated config stream is ready. How do I do that? Calling InitEngineXML() twice? Wouldn't that reset the logging that was set up earlier? > Within the engine, you need: > > - a new flag to have the session logger redirect its output to the > global logger, and also forwarding the flag to the > global logger such that it won't overwrite the beginning of the log. > Maybe some changes are needed to prevent re-instantiation of the > global logger at the second init, I'll have to check that. Does work for HTML? > - a way to send debug message from the outside (the app) into the > global log. Luckily, these already exist (Beat uses them exactly this > way in his test suite). See DB_DebugPuts, DB_DebugBlock, > DB_DebugEndBlock and DB_DebugEndThread entries in the UI_Call_In > record, or the ready-to-use wrappers for these in SDK_utils (DEBUG_xxx). I looked at those and found them a bit limited: only a single chunk of text can be passed to the engine, without information what kind of message it contains (important error message or just some developer debug stuff). The "logging" branch contains a tentative DebugPuts() call which accepts more information. The long-term goal is to actually put that information into the logs. > But if I'm correct, I think we have do a much less invasive solution - > and especially can avoid EVIL globals :-) Yes, using just one engine would be nice. -- Best Regards, Patrick Ohly The content of this message is my personal opinion only and although I am an employee of Intel, the statements I make here in no way represent Intel's position on the issue, nor am I authorized to speak on behalf of Intel on this matter. ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
On Wed, 2009-07-01 at 08:51 -0700, Patrick Ohly wrote: > On Wed, 2009-07-01 at 08:19 -0700, Lukas Zeller wrote: > > I don't see why you need two engines for that. You can initialize the > > same engine twice, once at the beginning with basically only the log > > options, and a second time when your generated config stream is ready. > > How do I do that? Calling InitEngineXML() twice? Wouldn't that reset the > logging that was set up earlier? There's one additional requirement: I also need to remove the datastores from the engine without shutting down the engine completely. That's because I want to continue writing to the log while the datastores clean up and after that is done. > > Within the engine, you need: > > > > - a new flag to have the session logger redirect its output to the > > global logger, and also forwarding the flag to the > > global logger such that it won't overwrite the beginning of the log. > > Maybe some changes are needed to prevent re-instantiation of the > > global logger at the second init, I'll have to check that. > > Does work for HTML? ... in particular considering that HTML and XML need opening and closing tags. The instance which starts an empty log could write the preamble, but who writes the end? -- Best Regards, Patrick Ohly The content of this message is my personal opinion only and although I am an employee of Intel, the statements I make here in no way represent Intel's position on the issue, nor am I authorized to speak on behalf of Intel on this matter. ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
Hi Patrick, On Jul 2, 2009, at 9:43 , Patrick Ohly wrote: On Wed, 2009-07-01 at 08:51 -0700, Patrick Ohly wrote: On Wed, 2009-07-01 at 08:19 -0700, Lukas Zeller wrote: I don't see why you need two engines for that. You can initialize the same engine twice, once at the beginning with basically only the log options, and a second time when your generated config stream is ready. How do I do that? Calling InitEngineXML() twice? Wouldn't that reset the logging that was set up earlier? There's one additional requirement: I also need to remove the datastores from the engine without shutting down the engine completely. That's because I want to continue writing to the log while the datastores clean up and after that is done. How do you define "remove"? Once the session completes or when you force it down by calling CloseSession() the session (TSyncSession descendants) and datastores (TSyncDatastore descendants) will automatically be deleted, taking down all plugin contexts in the process. Best Regards, Lukas Zeller (l...@synthesis.ch) - Synthesis AG, SyncML Solutions & Sustainable Software Concepts i...@synthesis.ch, http://www.synthesis.ch ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
Hi Patrick, I hit the send button to early for the previous mail. Here's the second half of the answer: On Jul 2, 2009, at 9:43 , Patrick Ohly wrote: Does work for HTML? ... in particular considering that HTML and XML need opening and closing tags. The instance which starts an empty log could write the preamble, but who writes the end? The TDebugLoggerBase object handles all this. The new which makes one logger use another for output using outputVia() makes sure that the preamble is not written in the middle of the global log. The end is written by the DebugFinalizeOutput() routine which is called when a logger is disposed. It tries to close the open blocks (only thise generate tags that span more than one message), and finally writes the suffix (like a closing . This routine tries to play nice even if the block hierarchy is not correct, but might still fail in some cases. Usually, a correct end is nice but not needed - the most interesting logs are those that abruptly end due to a crash anyway :-) Best Regards, Lukas Zeller (l...@synthesis.ch) - Synthesis AG, SyncML Solutions & Sustainable Software Concepts i...@synthesis.ch, http://www.synthesis.ch ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis
Re: [os-libsynthesis] unified log file
On Thu, 2009-07-02 at 05:03 -0700, Lukas Zeller wrote: > On Jul 2, 2009, at 9:43 , Patrick Ohly wrote: > > >> Does work for HTML? > > > > ... in particular considering that HTML and XML need opening and > > closing > > tags. The instance which starts an empty log could write the preamble, > > but who writes the end? > > The TDebugLoggerBase object handles all this. The new > which makes one logger use another for output > using outputVia() makes sure that the preamble is not written in the > middle of the global log. I gave this a try. I found that message dumping doesn't pick up the right path from the linked logger; an additional indirection via fOutputLoggerP is needed. I also tried re-initializing the engine with a second call to InitEngineXML(). This worked well, too, after disabling the check in the engine which makes datastore configs obligatory. I merged the Synthesis master and my own changes into the Moblin master. Lukas, if you agree with them, please merge back. Thanks a lot for introducing the much cleaner solution. It's a bit as in the Linux kernel: propose a crappy solution and someone will come up with something better. Some use this as a strategy to get things implemented; this wasn't my intention here ;-) The changes in SyncEvolution are a bit more intrusive (also include redirecting of stderr into the log). I'll ask someone from the team to double-check this and then might start using it in the next SyncEvolution snapshot. -- Best Regards Patrick Ohly Senior Software Engineer Intel GmbH Open Source Technology Center Hermuelheimer Strasse 8a Phone: +49-2232-2090-30 50321 Bruehl Fax: +49-2232-2090-29 Germany ___ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis