Jump to content

AutoIt ConsoleWrite + Android logcat


Page2PagePro
 Share

Recommended Posts

In an attempt to colorize the SciTE output pane while trying to leverage Android logcat filtering concept, I developed and use the following function.

;~ Example test vars to clarify all included vars are indeed in global scope
;~ The following five lines can be removed.
$var1 = 1
Local $var2 = 2
Global $var3 = 3
Const $var4 = 4
Global Const $var5 = 5

;~ ____________________________________________________________________________
Func cout($sMsg = "---------------", $sFlag = "", $bDTS = True, $sLF = @CRLF, $iScriptLine = @ScriptLineNumber)
    Local $sScriptLine = StringFormat('% 14s', '(' & $iScriptLine & ') ')
    Local $sPrefix = " ", $sSuffix = " "
    Switch StringUpper($sFlag)
        Case "S", "", 1
            $sScriptLine = StringFormat('% 14s', ":" & $iScriptLine & ': ')
        Case ">", "V", 2
            $sPrefix = '>'
        Case "*", "D", 3
            $sPrefix = '*'
        Case "-", "I", "<", 4
            $sPrefix = "-"
        Case "+", "W", 5
            $sPrefix = '+'
        Case "!", "E", 6
            $sPrefix = '!'
        Case "F", 7
            $sSuffix = ":"
    EndSwitch

    Local $sBase, $sDTS
    $sBase = $sPrefix & ' "' & @ScriptFullPath & '"' & $sScriptLine & $sSuffix
    $sDTS = (Not $bDTS ? "" : @HOUR & "|" & @MIN & "|" & @SEC & "." & @MSEC & " ")
    ConsoleWrite($sBase & " " & $sDTS & @TAB & @TAB & $sMsg & $sLF)
EndFunc   ;==>cout

Usage:

  • Place this along with other helpful functions and include
  • Use "S" (special), null, empty or integer 1 to allowing the lowest (most verbose) logging
  • "V", ">" or 2 for Verbose
  • "D", "*" or 3 for Debugging
  • etc.

Example:

#include "MyFunctions.au3"
cout()
cout("Test [")
cout(@TAB & "$var1 = " & $var1, "V")
cout(@TAB & "$var2 = " & $var2, "D")
cout(@TAB & "$var3 = " & $var3, "I")
cout(@TAB & "$var4 = " & $var4, "W")
cout(@TAB & "$var5 = " & $var5, "E")
cout("Test ]", "F")
cout()


cout(":default:", "F")
sleep(100)
cout(":warning:", "F")
sleep(100)
cout(":error:", "F")
sleep(100)
cout(":fatal:", "F")

I use a coloring theme to compliment Sublime and chose a ROYGBIV schema to my SciTEUser.properties file:

#~ Global Font
edge.column=80
font.base=font:Verdana,size:11,$(font.override)
font.monospace=font:Monaco,size:11
style.*.32=style.*.32=$(font.base),back:#F0F4F9

#~ Selection
selection.fore=#C00000
selection.back=#83675A
selection.alpha=25
highlight.current.word.colour=#DE9EAA

#~ Caret
caret.line.back=#4B3C34
caret.line.back.alpha=50
caret.width=3
caret.period=300
caret.fore=#37A8ED

# Code Color
style.au3.0=fore:#F8F8F8
style.au3.1=fore:#1E9AE0
style.au3.2=fore:#1E9AE0
style.au3.3=fore:#FF3A83
style.au3.4=fore:#0080FF,bold
style.au3.5=fore:#F6F080
style.au3.6=fore:#DADADA,bold
style.au3.7=fore:#55E439
style.au3.8=fore:#FFAA00
style.au3.9=fore:#FB9A4B
style.au3.10=fore:#DADADA
style.au3.11=fore:#FFAA00
style.au3.12=fore:#DADADA,italics,bold
style.au3.13=fore:#DADADA,bold
style.au3.14=fore:#DADADA,bold
style.au3.15=fore:#0080FF,bold
style.au3.16=fore:#0080FF
style.au3.32=style.*.32=$(font.base),back:#2A211C
style.au3.33=$(font.monospaced),fore:#E5C138,back:#4C4A41
style.au3.34=fore:#F6F080
style.au3.35=fore:#1E9AE0

#~ Folding
line.margin.visible=1
line.margin.width=5
margin.width=10
fold.symbols=2
fold.margin.colour=#2E3436
fold.margin.highlight.colour=#6A5448
fold.highlight.colour=#DC322F
fold.compact=0
fold.margin.width=12
output.initial.hide=1
error.marker.fore=#FF0000
error.marker.back=#2E3436

#~ Output Color ROYGBIV
style.errorlist.2=fore:#FF00FF      # 1
style.errorlist.21=fore:#FF99FF     # 1.5 FFFFFF
style.errorlist.4=fore:#800080      # 2
style.errorlist.0=fore:#1E9AE0      # 3
style.errorlist.12=fore:#007F00 # 4
style.errorlist.11=fore:#FFFF82 # 5
style.errorlist.10=fore:#FF8800 # 6
style.errorlist.3=fore:#FF3A83      # 7
style.errorlist.32=$(font.monospace),back:#2A211C

#~ INLINE ERRORS
error.inline=1
style.error.0=fore:#FFFFFF,back:#494846
style.error.1=fore:#FF0000,back:#FFFF00
style.error.2=fore:#FFFFFF,back:#FF6400
style.error.3=fore:#FFFFFF,back:#D00064

#~ Properties Color
style.props.0=fore:#000000,bold
style.props.1=fore:#009000,bold,$(font.comment)
style.props.2=$(colour.string),bold,back:#EFF0F0,eolfilled
style.props.3=fore:#FF0000,bold
style.props.4=$(colour.preproc)
style.props.5=fore:#0060E0,bold

Feedback and of course improvements encouraged!

 

 

SciTE_output_monaco_logcat.png

Edited by Page2PagePro
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...