Hi,
i found that logging strings with Logcolor truncates the string, using the usual Log the string is ok.
I'm using B4A V4.30
here is the code to demonstrate it :
B4X:
Sub ServerLog(AddLog As String)
'save the daily log
DateTime.DateFormat="yyyyMMdd"
AddLog=DateTime.Date(DateTime.Now) & "-" & DateTime.Time(DateTime.Now) & " Server: " & AddLog &CRLF
'LogColor(AddLog,Colors.Red)
Log(AddLog)
Dim DailyLog As String =DateTime.Date(DateTime.Now) &"_"& Main.LogFile
Dim FileOut As OutputStream=File.OpenOutput(Main.WkDir,DailyLog,True)
Dim Tw As TextWriter
Tw.Initialize(FileOut)
Tw.Write(AddLog)
Tw.Close
End Sub
in my case i'm trying to log a string containing an ip address, when logged in red the string is truncated, when logged normally the string is ok. Also the code saves the log in a file and it's correct in both cases.
I made two screenshots where you can see the behaviour
Sub Activity_Create(FirstTime As Boolean)
Dim AddLog As String =DateTime.Date(DateTime.Now) & "-" & DateTime.Time(DateTime.Now) & " Server: 2134234234234" &CRLF
LogColor(AddLog,Colors.Red)
End Sub
Hi Erel, thanks.
The log is OK with your example.
however i found that if you add another CRLF at the end of the string the bug appear:
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Dim AddLog As String =DateTime.Date(DateTime.Now) & "-" & DateTime.Time(DateTime.Now) & " Server: 2134234234234" &CRLF & CRLF
LogColor(AddLog,Colors.Red)
AddLog="number with dots: " & "123.456.789.123.456.789" & CRLF & CRLF
LogColor (AddLog,Colors.Red)
AddLog =DateTime.Date(DateTime.Now) & "-" & DateTime.Time(DateTime.Now) & " Server: current ip: 151.61.236.114" &CRLF & CRLF
LogColor (AddLog,Colors.Red)
End Sub
in fact, looking the images in my first post, there is an empty line after the logs, telling me that the CRLF is doubled.