[Gambas-user] Logger $(callLocation) always prints ComplexLogger.Log.60

Tobias Boege tobs at taboege.de
Tue Dec 21 21:50:20 CET 2021


On Tue, 21 Dec 2021, T Lee Davidson wrote:
> On 12/21/21 9:43 AM, Cristiano Guadagnino wrote:
> > Hi,
> > I am beginning to use the logging functions provided by gb.logging.
> > Unfortunately I found that, when using $(callLocation), the log always contains "ComplexLogger.Log.60". This is not very useful.
> > I did a search before posting this thread, and found an identical thread from 2018 which, however, did not contain any reply.
> > 
> > I can add some code if needed, but I'm not doing anything special.
> > I just instantiate a new Logger object, then use it, leaving most values (especially Format) to their defaults.
> > 
> > Thank you in advance for your help
> > Cris
> > cloudHQ <https://www.free-email-tracker.com>	Powered by
> > cloudHQ <https://www.free-email-tracker.com>	
> > 
> 
> I think it's a bug.
> 
> The function that populates the call location is in the Formatter Module [1] starting at line 7:
> Private Function GetCallLocation() As String
> 
>   Dim iCount As Integer = 1
> 
>   While System.Backtrace[iCount] Begins "Logger" Or System.Backtrace[iCount] Begins "Formatter"
>     Inc iCount
>   Wend
> 
>   Return System.Backtrace[iCount]
> 
> End
> 
> I think that While statement should be:
> While System.Backtrace[iCount] Begins "Log" Or System.Backtrace[iCount] Begins "Formatter"
> 

Yes, sounds about right. How about you make a merge request on Gitlab?

There are some other prefixes in that component like "FileHandler", but I
don't know if they can occur in the call paths of gb.logging and need to be
filtered out as well. Also note that this function may skip over the correct
call location from your project if you name your classes of modules "wrong",
but this is a problem that is independent of the current bug. [ Perhaps the
class names of gb.logging which need to be skipped in backtraces should be
listed explicitly, not using "Begins". ]

Best,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list