#1 2025-07-29 03:01:21

zen010101
Member
Registered: 2024-06-15
Posts: 124

Log Formatting Issue: Incorrect Indentation/Alignment

Offline

#2 2025-07-29 06:55:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,148
Website

Re: Log Formatting Issue: Incorrect Indentation/Alignment

I am sadly not able to reproduce.
No problem on my side using sllCustom1 for the logs (generating GB of multi-threaded logs).

I suspect it depends how you use it.
Indentation comes from recursive calls of Enter/Leave TSynLog methods.
I don't know what changed, but we need to reproduce the problem, and it sounds the issue may come from incorrect use, e.g. improper calls to ManualEnter, or invalid usage of ISynLog variable and its refcount.
The problem may not have been visible before the refactoring, but being there in the code.

Which levels do you set in your TSynLogFamily?

Please
1) ensure your code is correct (no memory leak or ISynLog refcount problems), and
2) provide a minimal reproducible example.

Offline

#3 2025-07-29 12:03:01

zen010101
Member
Registered: 2024-06-15
Posts: 124

Re: Log Formatting Issue: Incorrect Indentation/Alignment

I apologize for a typo in my initial post: the relevant commit hash is actually 8f94919cb664b73c26e856a8569725a97167a971. I've already corrected this in my comment on the commit: https://github.com/synopse/mORMot2/comm … -163041989

Here's some additional information that might help narrow down the issue:

  • Log Levels: This problem isn't tied to a specific log level. I've observed the same formatting corruption even when sllInfo and sllDebug levels are enabled, meaning it's not exclusive to sllCustom1.

  • Logging Methods: I am not using Enter or ManualEnter methods. My logging consistently follows this pattern:

    l: ISynLog;
    ...
    l := TSynLog.Add;
    l.Log(...)
  • Memory Leaks: I've thoroughly checked, and there are no memory leaks detected in my application.

  • ISynLog Reference Counting: I'm currently unsure how to effectively track ISynLog reference counts. Any advice or suggestions on how to monitor this would be very helpful.

  • Minimal Reproducible Example (MRE): I understand that an MRE is crucial for debugging, and I'm actively working on creating one. Unfortunately, I haven't completed it yet.

  • Application Overview: My application is a Web API Server. It handles incoming requests, initiates external program tasks, and then monitors their execution. All critical information—such as received requests, responses, task creation details, and real-time task status updates—is logged. If it would assist in your investigation, I can provide you with a full log file.

Last edited by zen010101 (2025-07-29 12:08:34)

Offline

#4 2025-07-29 15:45:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,148
Website

Re: Log Formatting Issue: Incorrect Indentation/Alignment

Sadly,

l: ISynLog;
...
l := TSynLog.Add;

is a completely wrong pattern.

You need to use either

l: TSynLog;
...
l := TSynLog.Add;

or

l: ISynLog;
...
l := TSynLog.Enter('methodname');

Offline

#5 2025-07-29 15:59:01

zen010101
Member
Registered: 2024-06-15
Posts: 124

Re: Log Formatting Issue: Incorrect Indentation/Alignment

You're absolutely right!

I realize now that in previous versions, I was indeed using l := TSynLog.Enter('methodname');. However, in the newer version, l could be nil, so I switched to l := TSynLog.Add;, not realizing that was an incorrect usage. Now that I've reverted to l: TSynLog, the error is gone.

Still, I'm quite curious why this incorrect usage didn't cause any issues before commit 8c0ca6456fa6622b032b7fa50b3f69e0b38f8028.

Offline

#6 2025-07-29 16:37:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,148
Website

Re: Log Formatting Issue: Incorrect Indentation/Alignment

My best guess is that is somewhat worked by chance/magic.
There are never been any true refcounted instance with ISynLog. But the refcount may have somewhat worked with the previous pattern.
In those commits, I rewrote the whole per-thread access for efficiency, so it could have been more sensitive.

Anyway, I have tried to refine the documentation to warn about such misuse:
https://github.com/synopse/mORMot2/commit/786d02cad

Edit:
I think the following may have been missing to protect from a wrongly used ISynLog instance:
https://github.com/synopse/mORMot2/commit/9c697274f

Offline

Board footer

Powered by FluxBB