| 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><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><strong>Email</strong></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>Email appender</h2> |
| 54 |
|
| 55 |
<p>This appender can be used to send log requests through email. One email |
| 56 |
message is sent for each log request.</p> |
| 57 |
|
| 58 |
<pre class="example"> |
| 59 |
function logging.email { |
| 60 |
from = <i>string</i>, |
| 61 |
rcpt = <i>string</i> or <i>string-table</i>, |
| 62 |
[user = <i>string</i>,] |
| 63 |
[password = <i>string</i>,] |
| 64 |
[server = <i>string</i>,] |
| 65 |
[port = <i>number</i>,] |
| 66 |
[domain = <i>string</i>,] |
| 67 |
[headers = <i>table</i>,] |
| 68 |
|
| 69 |
[logPattern = <i>string</i>,] |
| 70 |
[logPatterns = { |
| 71 |
[logging.DEBUG = <i>string</i>,] |
| 72 |
[logging.INFO = <i>string</i>,] |
| 73 |
[logging.WARN = <i>string</i>,] |
| 74 |
[logging.ERROR = <i>string</i>,] |
| 75 |
[logging.FATAL = <i>string</i>,] |
| 76 |
},] |
| 77 |
[timestampPattern = <i>string</i>,] |
| 78 |
[logLevel = <i>log-level-constant</i>,] |
| 79 |
} |
| 80 |
</pre> |
| 81 |
|
| 82 |
<ul> |
| 83 |
<li><code>from</code>:<br /> |
| 84 |
The sender of the email message.</li> |
| 85 |
|
| 86 |
<li><code>rcpt</code>:<br /> |
| 87 |
The recipient of the email message. A string or a numerically indexed Lua table with strings.</li> |
| 88 |
|
| 89 |
<li><code>user</code>:<br /> |
| 90 |
User for authentication.</li> |
| 91 |
|
| 92 |
<li><code>password</code>:<br /> |
| 93 |
Password for authentication.</li> |
| 94 |
|
| 95 |
<li><code>server</code>:<br /> |
| 96 |
Server to connect to. Default is <code>"localhost"</code>.</li> |
| 97 |
|
| 98 |
<li><code>port</code>:<br /> |
| 99 |
Port to connect to. Default is <code>25</code>.</li> |
| 100 |
|
| 101 |
<li><code>domain</code>:<br /> |
| 102 |
Domain name used to greet the server. Defaults to the local |
| 103 |
machine host name.</li> |
| 104 |
|
| 105 |
<li><code>headers.to</code>:<br /> |
| 106 |
The recipient of the message, as an extended description.</li> |
| 107 |
|
| 108 |
<li><code>headers.from</code>:<br /> |
| 109 |
The sender of the message, as an extended description.</li> |
| 110 |
|
| 111 |
<li><code>headers.subject</code>:<br /> |
| 112 |
The subject of the message sent. This can contain patterns like |
| 113 |
the <code>logPattern</code> parameter.</li> |
| 114 |
|
| 115 |
<li><code>logPatterns</code>:<br /> |
| 116 |
A table with logPattern strings indexed by the log-levels. |
| 117 |
A logPattern specifies how the message is written.<br /> |
| 118 |
If this parameter is omitted, a patterns table will be created with the |
| 119 |
parameter <code>logPattern</code> as the default value for each log-level. |
| 120 |
If <code>logPattern</code> also is omitted then each level will fall back to |
| 121 |
the current default setting, see <code>logging.defaultLogPatterns</code>. |
| 122 |
</li> |
| 123 |
|
| 124 |
<li><code>logPattern</code>:<br /> |
| 125 |
This value will be used as the default value for each log-level that was |
| 126 |
omitted in <code>logPatterns</code>. |
| 127 |
</li> |
| 128 |
|
| 129 |
<li><code>timestampPattern</code>:<br /> |
| 130 |
This is an optional parameter that can be used to specify a date/time formatting |
| 131 |
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li> |
| 132 |
|
| 133 |
<li><code>logLevel</code>:<br /> |
| 134 |
The initial log-level to set for the created logger.</li> |
| 135 |
</ul> |
| 136 |
|
| 137 |
<h2>Example</h2> |
| 138 |
|
| 139 |
<pre class="example"> |
| 140 |
require"logging.email" |
| 141 |
|
| 142 |
local logger = logging.email { |
| 143 |
rcpt = "[email protected]", |
| 144 |
from = "[email protected]", |
| 145 |
headers = { |
| 146 |
subject = "[%level] logging.email test", |
| 147 |
}, |
| 148 |
} |
| 149 |
|
| 150 |
logger:info("logging.email test") |
| 151 |
logger:debug("debugging...") |
| 152 |
logger:error("error!") |
| 153 |
</pre> |
| 154 |
|
| 155 |
</div> <!-- id="content" --> |
| 156 |
|
| 157 |
</div> <!-- id="main" --> |
| 158 |
|
| 159 |
<div id="about"> |
| 160 |
<p><a href="https://validator.w3.org/check?uri=referer"> |
| 161 |
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p> |
| 162 |
</div> <!-- id="about" --> |
| 163 |
|
| 164 |
</div> <!-- id="container" --> |
| 165 |
|
| 166 |
</body> |
| 167 |
</html> |