rfc3164
rfc3164 implementation in Erlang. Testing. Don't use it in production! ;)
This module was built with flexibility in mind. So, currently, this one will return standard and well used erlang datastructure:
- proplist
- map
- record
Build
$ rebar3 compile
Usage
By default, this library use proplists (tuple + lists):
RawPacket = <<"<0>1999 Oct 10 11:12:13 myhostname process[123]: message test">>
rfc3164:decode(RawPacket).
% return:
% [{message,<<"message test">>},
% {processid,123},
% {tag,<<"process">>},
% {hostname,<<"myhostname">>},
% {second,13},
% {minute,12},
% {hour,11},
% {day,10},
% {month,10},
% {year,1999},
% {severity,emerg}]
But, you can also use maps:
RawPacket = <<"<0>1999 Oct 10 11:12:13 myhostname process[123]: message test">>
rfc3164:decode(RawPacket, [{export, as_map}]).
% return:
% #{day => 10,
% hostname => <<"myhostname">>,
% hour => 11,
% message => <<"message test">>,
% minute => 12,
% month => 10,
% processid => 123,
% second => 13,
% severity => emerg,
% tag => <<"process">>,
% year => 1999}
And record with rfc3164 record defined in rfc3164_lib.hrl:
RawPacket = <<"<0>1999 Oct 10 11:12:13 myhostname process[123]: message test">>
rfc3164:decode(RawPacket, [{export, as_record}]).
% return:
% #rfc3164{priority = undefined, facility = kern,
% severity = emerg, year = 1999,
% month = 10, day = 10, hour = 11,
% minute = 12, second = 13,
% hostname = <<"myhostname">>,
% tag = <<"process">>, processid = 123,
% message = <<"message test">>}
Todo list
- Support validation
- Rename interfaces
- Rewrite specifications
- Add more datastructure (record and AST)
- Benchmark
- Unit test
- Documentation
References
Description
Languages
Erlang
100%