Table of Contents
List of Examples
base_folder
parameterfile
parameterworker_usleep
parameterfile_out
usageTable of Contents
This is a small module to support fast streaming output to files and process this changes depending on an interval. It implements only one function that streams a chunk of text to the current output file handle.
The module can be used to write logs for up to 10 different log files. Each log file can be configured to have a different name and extension. The processed string can contain pseudo-variables. The module will replace the pseudo-variables with the actual values. The module will also rotate the log files at a specified interval. The interval is specified in seconds.
Known limitations on the rotation interval are:
If there is no messages coming, the rotation will not be done until the next message arrives.
Absolute path to the folder where log files should be saved.
Default value is “/var/log/kamailio/file_out”.
Example 1.1. Set base_folder
parameter
... modparam("file_out", "base_folder", "/tmp/file_out") # trailing slash will be added. ...
The definition of a file and its properties. The value of the parameter may have the following format:
"name=accounting;extension=.out;interval=20;prefix=accounting:"
The parameter can be set multiple times to define more files in same configuration file.
name (Required) - the name of the file
No default value. This parameter is required.
extension (Optional) - the extension of the file
Default value is “.out”.
interval (Optional) - the interval in seconds of the file rotation
Default value is “600” (10min).
prefix (Optional) - the prefix for log messages
Default value is “""” (empty string).
Example 1.2. Set file
parameter
... modparam("file_out", "file", "name=missed_calls;interval=30;extension=.json") modparam("file_out", "file", "name=accounting;extension=.txt") ...
This function is used to write a string to a file. The file is determined by the filename parameter. The string parameter is the string to be written to the file. Filename is the name of the file defined in the configuration file as name=filename.
Example 1.4.
file_out
usage
... modparam("file_out", "file", "name=accounting;interval=200") modparam("file_out", "file", "name=missed_calls;extension=.json;interval=300") request_route { file_out("accounting", "Writing to accounting.out file $rm from $fu"); file_out("missed_calls", "Writing to missed_calls.out file $rm from $fu"); } ...