Bug? Logcolor statement truncates strings

Discussion in 'Bugs & wishlist' started by DavideV, Mar 14, 2015.

  1. DavideV

    DavideV Active Member Licensed User

    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 :

    Code:
    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

    Bye
    DavideV

    log_good.png logcolor_wrong.png
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please create a new project and run this code:
    Code:
    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
    Are the logs truncated here?
     
  3. DavideV

    DavideV Active Member Licensed User

    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:

    Code:
    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.
     
    Peter Simpson likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    I see it too. It is fixed for the next version.
     
    Peter Simpson and DavideV like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice