Debian Codegraph @

docs/file.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
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><strong>File</strong></li>
38 <li><a href="rolling_file.html">Rolling File</a></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>File appender</h2>
54
55 <p>The file appender can be used to write log messages to a file. It
56 uses Lua I/O routines to do its job.</p>
57
58 <pre class="example">
59 function logging.file {
60 [filename = <i>string</i>,]
61 [datePattern = <i>string</i>,]
62
63 [logPattern = <i>string</i>,]
64 [logPatterns = {
65 [logging.DEBUG = <i>string</i>,]
66 [logging.INFO = <i>string</i>,]
67 [logging.WARN = <i>string</i>,]
68 [logging.ERROR = <i>string</i>,]
69 [logging.FATAL = <i>string</i>,]
70 },]
71 [timestampPattern = <i>string</i>,]
72 [logLevel = <i>log-level-constant</i>,]
73 }
74 </pre>
75
76 <ul>
77 <li><code>filename</code>:<br />
78 The name of the file to be written to. On each call to log a
79 message the file is opened for appending and closed immediately.<br />
80 If the file cannot be opened for appending the logging request
81 returns nil and an error message.<br />
82 The default value is <code>"lualogging.log"</code>.</li>
83
84 <li><code>datePattern</code>:<br />
85 This is an optional parameter that can be used to specify a date
86 pattern that will be passed to the
87 <a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.date"><code>os.date</code></a>
88 function to compose the filename.<br />
89 This is useful to create daily or monthly log files. If the user
90 wants to create one log file per day he specifies a
91 <code>"%Y-%m-%d"</code> pattern and a filename like
92 <code>"temp%s.log"</code>.</li>
93
94 <li><code>logPatterns</code>:<br />
95 A table with logPattern strings indexed by the log-levels.
96 A logPattern specifies how the message is written.<br />
97 If this parameter is omitted, a patterns table will be created with the
98 parameter <code>logPattern</code> as the default value for each log-level.
99 If <code>logPattern</code> also is omitted then each level will fall back to
100 the current default setting, see <code>logging.defaultLogPatterns</code>.
101 </li>
102
103 <li><code>logPattern</code>:<br />
104 This value will be used as the default value for each log-level that was
105 omitted in <code>logPatterns</code>.
106 </li>
107
108 <li><code>timestampPattern</code>:<br />
109 This is an optional parameter that can be used to specify a date/time formatting
110 in the log message.
111 See <code>logging.date</code> for the format.
112 The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
113
114 <li><code>logLevel</code>:<br />
115 The initial log-level to set for the created logger.</li>
116 </ul>
117
118 <h2>Example</h2>
119
120 <pre class="example">
121 require"logging.file"
122
123 local logger = logging.file {
124 filename = "test%s.log",
125 datePattern = "%Y-%m-%d",
126 }
127
128 logger:info("logging.file test")
129 logger:debug("debugging...")
130 logger:error("error!")
131 </pre>
132
133 <p>&nbsp;</p>
134 <p>&nbsp;</p>
135
136 </div> <!-- id="content" -->
137
138 </div> <!-- id="main" -->
139
140 <div id="about">
141 <p><a href="https://validator.w3.org/check?uri=referer">
142 <img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 v&aacute;lido!" height="31" width="88" /></a></p>
143 </div> <!-- id="about" -->
144
145 </div> <!-- id="container" -->
146
147 </body>
148 </html>