Bark contains a client library which can be imported in a Golang project. Now, logs in bark are actually structured. They have a Level, a LMID and the actual message. So we wrote a parser which tries parse the log message and if it fits the formats, it would set the level and LMID along with the Log message.

The Format and Behaviour

The general format of the Log message which the parser understands (and expects) is like this:


These fields are:

  1. LVL_CHAR: is a single character indicating the log severity level. The accepted characters are basically the first character of their names:
    • P: Panic
    • A: Alert
    • E: Error
    • W: Warning
    • N: Notice
    • I: Info
    • D: Debug
  2. LMID: Is the Log Message Identifier. It is separated on the left from LVL_CHAR by a # and on the right from the LOG_MESSAGE by a -. The spaces around - are optional but recommended to be left as it is.
  3. LOG_MESSAGE: This is the actual Log Message which the user wants to save.

It is worth noting that:

  • If the LVL_CHAR is set to anything else, it will automatically be set to the default log level set by the user when creating the client.
  • <LVL_CHAR># (the LVL_CHAR along with #) is optional. When it is missing, the default log level will be used instead.

It is best to demonstrate the behavior with examples.


Here is how it behaves with various inputs:

Input stringLevelLog Message IDLog message
D#LMID1 - Log messageDEBUGLMID1Log message
I#LMID2 - Log message2INFOLMID2Log message2
N#LMID3 - Log message3NOTICELMID3Log message3
W#LMID4 - Log message4WARNLMID4Log message4
E#LMID5 - Log message5ERRORLMID5Log message5
A#LMID6 - Log message6ALERTLMID6Log message6
P#LMID7 - Log message7ERRORLMID7Log message7
LMID2 - Log message8INFOLMID2Log message8
Log message9INFO000000Log message9
- Log message10INFO000000- Log message10
# - Log message11INFO000000 # - Log message11
X# - Log message12INFO000000X# - Log message12
XX# - Log message13INFO000000XX# - Log message13
XX#LMID14 - Log message14INFO000000XX#LMID14 - Log message14
#LMID17 - Log message17INFO000000#LMID17 - Log message17
D#LMID18 - Log message18DEBUGLMID18Log message18
D # LMID19 - Log message19DEBUGLMID19Log message19
(blank string)INFO000000(blank string)
(whitespace)INFO000000(blank string)