Modifying the on-the-wire message format
Macros, templates, and template functions allow you to fully customize the format of the message. This flexibility makes it possible to use AxoSyslog in some unexpected way if needed, for example, to emulate simple, plain-text protocols. The following example shows you how to send LPUSH commands to a Redis server.
Note
The purpose of this example is to demonstrate the flexibility of AxoSyslog. A dedicated Redis destination is available in AxoSyslog version 3.5. For details, see redis: Store name-value pairs in Redis.
The following template is a valid LPUSH command in accordance with the Redis protocol, and puts the $MESSAGE into a separate list for every $PROGRAM:
template t_redis_lpush {
template("*3\r\n$$5\r\nLPUSH\r\n$$$(length ${PROGRAM})\r\n${PROGRAM}\r\n$$$(length ${MESSAGE})\r\n${MESSAGE}\r\n");
};
If you use this template in a network()
destination, AxoSyslog formats the message according to the template, and sends it to the Redis server.
destination d_redis_tcp {
network("127.0.0.1" port(6379) template(t_redis_lpush));
};
Last modified December 18, 2024: Merge pull request #90 from axoflow/minor-fixes-241218 (68cd7df)