Android Question What happens to "Log" methods during compilation?

David Martinez

Member
Licensed User
Longtime User
Curious performance question....

What happens to "Log" methods during compilation in Release mode?

Should I comment them out, removed them or ignore them before I compile a final release?

Thanks
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
For what it's worth, I create two subs in every project in my main module and call them:
B4X:
Public Sub MyLog(Text As String)
    #If DEBUG
        LogColor(Text, Colors.Magenta)
    #End If
End Sub

Public Sub MyLogError(Routine As String, Text As String)
    LogColor("Source: [" & Routine & "]  Error:" & Text, Colors.Red)
End Sub
That way, in my code I can use module.MyLog(...) for debugging and module.MyLogError(...) for log statements I want regardless of which mode I'm in.

See this discussion for more information:https://www.b4x.com/android/forum/threads/programatically-check-for-debug.30296/#post-175950
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…