Skip to content

Instantly share code, notes, and snippets.

@wizardjedi
Last active January 3, 2018 13:49
Show Gist options
  • Save wizardjedi/694c3fb422027f26becb1a41c95e9f48 to your computer and use it in GitHub Desktop.
Save wizardjedi/694c3fb422027f26becb1a41c95e9f48 to your computer and use it in GitHub Desktop.
Compact log definition

Structured log commands

Introduce template

01 log level logger id TplId Tpl body

Introduce date

02 date

date = Year-Month-day

Introduce time

03 time

time = Hour:Minute

Row

04 Seconds + millis tpl id Params

Introduce logger

05 loggerid logger name

Introduce string

06 encoding string id string 0x00

Introduce CRC32

07 CRC32

Introduce param

08 Paramid Param name

Data values

Half byte

Data range: -63 .. 64

flag = 1
7 6 5 4 3 2 1 0
0 Sign d5 d4 d3 d2 d2 d0

Special flags

flag = 10
7 6 5 4 3 2 1 0
1 0 F5 F4 F3 F2 F1 F0
F5 F4 F3 F2 F1 F0 Description
0 0 0 0 0 0 Null

Lengthed int

Data range = Length + 1 byted integer

flag = 110
length = 5 bit
7 6 5 4 3 2 1 0
1 1 0 l4 l3 l2 l1 l0
.. .. .. .. .. .. .. ..
7 6 5 4 3 2 1 0
d7 d6 d5 d4 d3 d2 d2 d0

Floating point value

flag = 1110
7 6 5 4 3 2 1 0
1 1 1 0 - - - -
.. .. .. .. .. .. .. ..
d7 d6 d5 d4 d3 d2 d2 d0

Datetime + UUID

flag = 11110
7 6 5 4 3 2 1 0
1 1 1 1 0 F2 F1 F0
.. .. .. .. .. .. .. ..
F2 F1 F0 Type
0 0 0 UUID
0 0 1 Date
0 1 0 Time
0 1 1 Date + Time
1 .. .. Reserved

flag = 111110
7 6 5 4 3 2 1 0
1 1 1 1 1 0 - -
.. .. .. .. .. .. .. ..

String

flag = 111111
encoding = 0 - utf-8 / 1 - latin-1
in place = 0 - use string id / 1 - in place string
7 6 5 4 3 2 1 0
1 1 1 1 1 1 encoding in place
.. .. .. .. .. .. .. ..
d7 d6 d5 d4 d3 d2 d2 d0
0 0 0 0 0 0 0 0

Archive file format

archive:[SCHEMA]
bunch:[SIZE]
[bunch data]
bunch:[SIZE]
[bunch data]
...
bunch:[SIZE]
[bunch data]

Common rules

  • value - value itself
  • [count]*value - duplicate value count times
  • \N - null-reference represent null value
  • '=' - separator for prefix and repetition group

Example

archive:transaction_id=integer,sms_text=text,add_date=date,delivered_count=integer
bunch:3
1025456122=0;1;2
3*"This is sms text"
1506862923=0;10;20
0=3*1

equals to

transaction_id;sms_text;add_date;delivered_count
1025456122;"This is sms text";"2017-10-01 16:02:03";1
1025456123;"This is sms text";"2017-10-01 16:02:13";1
1025456124;"This is sms text";"2017-10-01 16:02:23";1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment