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
 

DonManfred

Expert
Licensed User
Longtime User
Logs stay in your app if you don´t limit them to DEBUG or RELEASE

B4X:
    #if debug
        Log("log only in debug mode")
    #end if
    #if release
        Log("log only in release mode")
    #end if
 
Upvote 0

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
Top