Debian Codegraph @

src/modules/file_out/README

raw
1 file_out Module
2
3 Xenofon Karamanos
4
5 GILAWA Ltd
6 <[email protected]>
7
8 Copyright © 2024 GILAWA Ltd
9 __________________________________________________________________
10
11 Table of Contents
12
13 1. Admin Guide
14
15 1. Overview
16 2. Dependencies
17
18 2.1. Kamailio Modules
19 2.2. External Libraries or Applications
20
21 3. Parameters
22
23 3.1. base_folder (string)
24 3.2. file (string)
25 3.3. worker_usleep (int)
26 3.4. timer_interval (int)
27
28 4. Functions
29
30 4.1. file_out(filename, string)
31
32 5. Exported pseudo-variables
33
34 List of Examples
35
36 1.1. Set base_folder parameter
37 1.2. Set file parameter
38 1.3. Set worker_usleep parameter
39 1.4. Set timer_interval parameter
40 1.5. file_out usage
41
42 Chapter 1. Admin Guide
43
44 Table of Contents
45
46 1. Overview
47 2. Dependencies
48
49 2.1. Kamailio Modules
50 2.2. External Libraries or Applications
51
52 3. Parameters
53
54 3.1. base_folder (string)
55 3.2. file (string)
56 3.3. worker_usleep (int)
57 3.4. timer_interval (int)
58
59 4. Functions
60
61 4.1. file_out(filename, string)
62
63 5. Exported pseudo-variables
64
65 1. Overview
66
67 This is a small module to support fast streaming output to files and
68 process this changes depending on an interval. It implements only one
69 function that streams a chunk of text to the current output file
70 handle.
71
72 The module can be used to write logs for up to 10 different log files.
73 Each log file can be configured to have a different name and extension.
74 The processed string can contain pseudo-variables. The module will
75 replace the pseudo-variables with the actual values. The module will
76 also rotate the log files at a specified interval. The interval is
77 specified in seconds.
78
79 Known limitations on the rotation interval are:
80 * If there is no messages coming, the rotation will not be done until
81 the next message arrives.
82
83 2. Dependencies
84
85 2.1. Kamailio Modules
86 2.2. External Libraries or Applications
87
88 2.1. Kamailio Modules
89
90 The following modules must be loaded before this module:
91 * none.
92
93 2.2. External Libraries or Applications
94
95 The following libraries or applications must be installed before
96 running Kamailio with this module loaded:
97 * none.
98
99 3. Parameters
100
101 3.1. base_folder (string)
102 3.2. file (string)
103 3.3. worker_usleep (int)
104 3.4. timer_interval (int)
105
106 3.1. base_folder (string)
107
108 Absolute path to the folder where log files should be saved.
109
110 Default value is “/var/log/kamailio/file_out”.
111
112 Example 1.1. Set base_folder parameter
113 ...
114 modparam("file_out", "base_folder", "/tmp/file_out") # trailing slash will be ad
115 ded.
116 ...
117
118 3.2. file (string)
119
120 The definition of a file and its properties. The value of the parameter
121 may have the following format:
122 * "name=accounting;extension=.out;interval=20;prefix=accounting:"
123
124 The parameter can be set multiple times to define more files in same
125 configuration file.
126 * name (Required) - the name of the file
127 No default value. This parameter is required.
128 * extension (Optional) - the extension of the file
129 Default value is “.out”.
130 * interval (Optional) - the interval in seconds of the file rotation
131 Default value is “600” (10min).
132 * prefix (Optional) - the prefix for log messages
133 Default value is “""” (empty string).
134
135 Example 1.2. Set file parameter
136 ...
137 modparam("file_out", "file", "name=missed_calls;interval=30;extension=.json")
138 modparam("file_out", "file", "name=accounting;extension=.txt")
139 ...
140
141 3.3. worker_usleep (int)
142
143 The time in microseconds which worker will sleep for until next
144 iteration.
145
146 Default value is “10000” (10 ms).
147
148 Example 1.3. Set worker_usleep parameter
149 ...
150 modparam("file_out", "worker_usleep", 1000)
151 ...
152
153 3.4. timer_interval (int)
154
155 The time in seconds which timer will trigger for rotating the files.
156 Make sure that this value is lower than the interval of the files.
157
158 Default value is “10” (10 s).
159
160 Example 1.4. Set timer_interval parameter
161 ...
162 modparam("file_out", "timer_interval", 60)
163 ...
164
165 4. Functions
166
167 4.1. file_out(filename, string)
168
169 4.1. file_out(filename, string)
170
171 This function is used to write a string to a file. The file is
172 determined by the filename parameter. The string parameter is the
173 string to be written to the file. Filename is the name of the file
174 defined in the configuration file as name=filename.
175
176 Example 1.5. file_out usage
177 ...
178 modparam("file_out", "file", "name=accounting;interval=200")
179 modparam("file_out", "file", "name=missed_calls;extension=.json;interval=300")
180
181 request_route {
182 file_out("accounting", "Writing to accounting.out file $rm from $fu");
183 file_out("missed_calls", "Writing to missed_calls.out file $rm from $fu"
184 );
185 }
186 ...
187
188 5. Exported pseudo-variables
189
190 * none.