Skip to content

fosskers/logfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logfmt

This library is a parser for the logfmt style of logging messages.

level=info msg="Hello there!" foo=3 bar=ok

Table of Contents

API

parse

Parse a single log line into a Hash Table.

(logfmt:parse "level=info msg=\"Hello there!\" foo=3 bar=ok")
#<HASH-TABLE :TEST EQUAL :COUNT 4 {12016FB513}>

Numbers are parsed as numbers, but everything else is taken as-is as a string.

(1+ (gethash "foo" (logfmt:parse "level=info msg=\"Hello there!\" foo=3 bar=ok")))
4

safe-parse

parse will signal a Condition if parsing failed, but safe-parse will just yield nil.

(logfmt:safe-parse "level=info BAD msg=\"Hello there!\" foo=3 bar=ok")
NIL

read-file-into-string

A fast, compatible way to read the contents of a file into a string.

(length (logfmt:read-file-into-string #p"README.org"))
937

You could then run parse across each line.

About

Parser for the logfmt logging style

Resources

License

Stars

Watchers

Forks

Contributors