what is the best Way to save the Debug Log in File, if the user it switch on (i will it enabel/disable with a switch)?
my idea is to call a sub instead of Log(...)
B4X:
Sub WriteLogToFile(txt As String)
Log(txt)
Dim txtWriter As TextWriter
txtWriter.Initialize(File.OpenOutput(File.DirData("MyApp"),"Logfile.txt",True))
txtWriter.WriteLine(txt)
txtWriter.Close
End Sub
Name: RedirectOutput Description: This sub will redirect the program output to a file. Sub RedirectOutput (Dir As String, FileName As String) #if RELEASE Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) 'Set to True to append the logs Dim ps As JavaObject...
' when developing - dont enable it. This way your logs tab will show everything in debug and release...
(where production is a global public boolean var)