Debian Codegraph @

docs/rolling_file.html

raw ◀ ▶
1 Debian patch touch this file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>LuaLogging: A simple API to use logging features in Lua</title>
6 <link rel="stylesheet" href="doc.css" type="text/css"/>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8 </head>
9 <body>
10
11 <div id="container">
12
13 <div id="product">
14 <div id="product_logo">
15 <img alt="LuaLogging logo" src="images/lualogging-128.png"/>
16 </div>
17 <div id="product_name"><big><strong>LuaLogging</strong></big></div>
18 <div id="product_description">A simple API to use logging features in Lua.</div>
19 </div> <!-- id="product" -->
20
21 <div id="main">
22
23 <div id="navigation">
24 <h1>LuaLogging</h1>
25 <ul>
26 <li><a href="index.html">Home</a></li>
27 <li><a href="manual.html">Manual</a>
28 <ul>
29 <li><a href="manual.html#installation">Installation</a></li>
30 <li><a href="manual.html#logger">Logger objects</a></li>
31 <li><a href="manual.html#examples">Examples</a></li>
32 </ul>
33 </li>
34 <li><a href="manual.html#appenders">Appenders</a>
35 <ul>
36 <li><a href="console.html">Console</a></li>
37 <li><a href="file.html">File</a></li>
38 <li><strong>Rolling File</strong></li>
39 <li><a href="sql.html">SQL</a></li>
40 <li><a href="socket.html">Socket</a></li>
41 <li><a href="rsyslog.html">Rsyslog</a></li>
42 <li><a href="email.html">Email</a></li>
43 <li><a href="nginx.html">Nginx</a></li>
44 </ul>
45 </li>
46 <li><a href="https://github.com/lunarmodules/lualogging">Project</a></li>
47 <li><a href="license.html">License</a></li>
48 </ul>
49 </div> <!-- id="navigation" -->
50
51 <div id="content">
52
53 <h2>Rolling File appender</h2>
54
55 <p>The rolling file appender can be used to write log messages to a file. It
56 uses Lua I/O routines to do its job. The rolling file appender rolls over the logfile
57 once it has reached a certain size limit. It also mantains a maximum number of log files.</p>
58
59 <pre class="example">
60 function logging.rolling_file {
61 [filename = <i>string</i>,]
62 maxFileSize = <i>number</i>,
63 [maxBackupIndex = <i>number</i>,]
64
65 [logPattern = <i>string</i>,]
66 [logPatterns = {
67 [logging.DEBUG = <i>string</i>,]
68 [logging.INFO = <i>string</i>,]
69 [logging.WARN = <i>string</i>,]
70 [logging.ERROR = <i>string</i>,]
71 [logging.FATAL = <i>string</i>,]
72 },]
73 [timestampPattern = <i>string</i>,]
74 [logLevel = <i>log-level-constant</i>,]
75 }
76 </pre>
77
78 <ul>
79 <li><code>filename</code>:<br />
80 The name of the file to be written to.<br />
81 If the file cannot be opened for appending the logging request
82 returns nil and an error message.<br />
83 The default value is <code>"lualogging.log"</code>.</li>
84
85 <li><code>maxFileSize</code>:<br />
86 The max size of the file in bytes. Every time the file reaches this size
87 it will rollover, generating a new clean log file and storing the old log
88 on a filename.n, where n goes from 1 to the configured maxBackupIndex.<br />
89 The more recent backup is the one with the lowest n on its filename.<br />
90 Eg. test.log.1 (most recent backup) <br />
91 test.log.2 (least recent backup)
92 </li>
93
94 <li><code>maxBackupIndex</code>:<br />
95 The number of backup files that will be generated.
96 The default value is <code>1</code>.</li>
97
98 <li><code>logPatterns</code>:<br />
99 A table with logPattern strings indexed by the log-levels.
100 A logPattern specifies how the message is written.<br />
101 If this parameter is omitted, a patterns table will be created with the
102 parameter <code>logPattern</code> as the default value for each log-level.
103 If <code>logPattern</code> also is omitted then each level will fall back to
104 the current default setting, see <code>logging.defaultLogPatterns</code>.
105 </li>
106
107 <li><code>logPattern</code>:<br />
108 This value will be used as the default value for each log-level that was
109 omitted in <code>logPatterns</code>.
110 </li>
111
112 <li><code>timestampPattern</code>:<br />
113 This is an optional parameter that can be used to specify a date/time formatting
114 in the log message.
115 See <code>logging.date</code> for the format.
116 The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
117
118 <li><code>logLevel</code>:<br />
119 The initial log-level to set for the created logger.</li>
120 </ul>
121
122 <h2>Example</h2>
123
124 <pre class="example">
125 require"logging.rolling_file"
126
127 local logger = logging.rolling_file {
128 filename = "test.log",
129 maxFileSize = 1024,
130 maxBackupIndex = 5,
131 }
132
133 logger:info("logging.rolling_file test")
134 logger:debug("debugging...")
135 logger:error("error!")
136 </pre>
137
138 <p>&nbsp;</p>
139 <p>&nbsp;</p>
140
141 </div> <!-- id="content" -->
142
143 </div> <!-- id="main" -->
144
145 <div id="about">
146 </div> <!-- id="about" -->
147
148 </div> <!-- id="container" -->
149
150 </body>
151 </html>