Android Question Colorful Logs...

TheWind777

Active Member
Licensed User
Sometimes I just take a break from heavy-duty programming and fool around... ;)

This is one tip which is easy to add to your programs and greatly lets you see what's happening in the log window; great to use when you're debugging things.

COLOR

B4X:
Sub Activity_Create
  LogR("Test") ' Red
  LogO("Test") ' Orange
  LogG("Test") ' Green
  LogB("Test") ' Blue
  LogM("Test") ' Magenta
  LogV("Test") ' Violet
  LogBG("Test") ' Blue-green
end sub

Sub LogR(text As String)
  Dim BktLeft As String = Chr(171) & Chr(171) & Chr(171) & " "
  Dim BktRight As String = " " & Chr(187) & Chr(187) & Chr(187)
  LogColor(BktLeft & text & BktRight,Colors.Red)
End Sub

Sub LogO(text As String)
  Dim CopyrightL As String = Chr(169) & Chr(169) & Chr(169) & " "
  Dim CopyrightR As String = " " & Chr(169) & Chr(169) & Chr(169)
  LogColor(CopyrightL & text & CopyrightR,Colors.RGB(255,128,0))
End Sub

Sub LogG(text As String)
  Dim ParagraphL As String = Chr(182) & Chr(182) & Chr(182) & " "
  Dim ParagraphR As String = " " & Chr(182) & Chr(182) & Chr(182)
  LogColor(ParagraphL & text & ParagraphR,Colors.Green)
End Sub

Sub LogB(text As String)
  Dim BetaL As String = Chr(223) & Chr(223) & Chr(223) & " "
  Dim BetaR As String = " " & Chr(223) & Chr(223) & Chr(223)
  LogColor(BetaL & text & BetaR,Colors.Blue)
End Sub

Sub LogM(text As String)
  Dim CrossL As String = Chr(134) & Chr(134) & Chr(134) & " "
  Dim CrossR As String = " " & Chr(134) & Chr(134) & Chr(134)
  LogColor(CrossL & text & CrossR,Colors.RGB(255,0,255))
End Sub

Sub LogV(text As String)
  Dim CircleL As String = Chr(248) & Chr(248) & Chr(248) & " "
  Dim CircleR As String = " " & Chr(248) & Chr(248) & Chr(248)
  LogColor(CircleL & text & CircleR,Colors.RGB(128,0,255))
End Sub

Sub LogBG(text As String)
  Dim LittleXL As String = Chr(215) & Chr(215) & Chr(215) & " "
  Dim LittleXR As String = " " & Chr(215) & Chr(215) & Chr(215)
  LogColor(LittleXL & text & LittleXR,Colors.RGB(0,153,153))
End Sub
The HTML Code would look like this. I was hoping that this website allowed the embedding of HTML in the code, but apparently not.

HTML:
<br><font color = "red">&#171;&#171;&#171; Test &#187;&#187;&#187;</font><br>
<font color = "RGB(255,128,0)">&#169;&#169;&#169; Test &#169;&#169;&#169;</font><br>
<font color = "green">&#182;&#182;&#182; Test &#182;&#182;&#182;</font><br>
<font color = "blue">&#223;&#223;&#223; Test &#223;&#223;&#223;</font><br>
<font color = "RGB(255,0,255)">&#134;&#134;&#134; Test &#134;&#134;&#134;</font><br>
<font color = "RGB(128,0,255)">&#248;&#248;&#248; Test &#248;&#248;&#248;</font><br>
<font color = "RGB(0,153,153)">&#215;&#215;&#215; Test &#215;&#215;&#215;</font><br>
And, if you wanted to pick the characters that you think stand-out the best run this:

B4X:
Sub ShowAll(BlankString As String) as String
  Dim ReturnStr As String
  Dim z As Int
  Dim CARRETURNLINEFEED As String = Chr(13) & Chr(10)

  For z = 128 To 255
    ReturnStr = ReturnStr & z & " = " & Chr(z) & CARRETURNLINEFEED
  Next

  Log(ReturnStr)
  Return ReturnStr
end sub
 
Last edited:
Top