bunkerweb 1.4.0
This commit is contained in:
19
deps/src/lualogging/.editorconfig
vendored
Normal file
19
deps/src/lualogging/.editorconfig
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
[*.lua]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.html]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
29
deps/src/lualogging/.github/workflows/test.yml
vendored
Normal file
29
deps/src/lualogging/.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
luaVersion: ["5.1", "5.2", "5.3", "5.4", "luajit"]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: leafo/gh-actions-lua@v8.0.0
|
||||
with:
|
||||
luaVersion: ${{ matrix.luaVersion }}
|
||||
|
||||
- uses: leafo/gh-actions-luarocks@v4.0.0
|
||||
|
||||
- name: setup
|
||||
run: |
|
||||
luarocks make
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
make test
|
||||
2
deps/src/lualogging/.gitignore
vendored
Normal file
2
deps/src/lualogging/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
tests/test.log*
|
||||
*.rock
|
||||
35
deps/src/lualogging/.luacheckrc
vendored
Normal file
35
deps/src/lualogging/.luacheckrc
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
--std = "ngx_lua+busted"
|
||||
unused_args = false
|
||||
redefined = false
|
||||
max_line_length = false
|
||||
|
||||
|
||||
globals = {
|
||||
--"_KONG",
|
||||
--"kong",
|
||||
--"ngx.IS_CLI",
|
||||
}
|
||||
|
||||
|
||||
not_globals = {
|
||||
"string.len",
|
||||
"table.getn",
|
||||
}
|
||||
|
||||
|
||||
ignore = {
|
||||
--"6.", -- ignore whitespace warnings
|
||||
}
|
||||
|
||||
|
||||
exclude_files = {
|
||||
"here/**",
|
||||
"lua_install/**",
|
||||
"dos/**",
|
||||
--"spec/fixtures/invalid-module.lua",
|
||||
--"spec-old-api/fixtures/invalid-module.lua",
|
||||
}
|
||||
|
||||
files["src/logging/nginx.lua"] = {
|
||||
std = "+ngx_lua"
|
||||
}
|
||||
20
deps/src/lualogging/COPYRIGHT
vendored
Normal file
20
deps/src/lualogging/COPYRIGHT
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2004-2021 Kepler Project.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
18
deps/src/lualogging/Makefile
vendored
Normal file
18
deps/src/lualogging/Makefile
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# Default prefix
|
||||
PREFIX = /usr/local
|
||||
|
||||
# System's lua directory (where Lua libraries are installed)
|
||||
LUA_DIR= $(PREFIX)/share/lua/5.1
|
||||
|
||||
LUAS= src/logging/console.lua src/logging/email.lua src/logging/file.lua src/logging/rolling_file.lua src/logging/socket.lua src/logging/sql.lua src/logging/nginx.lua
|
||||
ROOT_LUAS= src/logging.lua
|
||||
|
||||
build clean:
|
||||
|
||||
install:
|
||||
mkdir -p $(LUA_DIR)/logging
|
||||
cp $(LUAS) $(LUA_DIR)/logging
|
||||
cp $(ROOT_LUAS) $(LUA_DIR)
|
||||
|
||||
test:
|
||||
cd tests && ./run_tests.sh
|
||||
12
deps/src/lualogging/Makefile.win
vendored
Normal file
12
deps/src/lualogging/Makefile.win
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
LUA_DIR= c:\lua5.1\lua
|
||||
|
||||
LUAS= src\logging\console.lua src\logging\email.lua src\logging\file.lua src\logging\rolling_file.lua src\logging\socket.lua src\logging\sql.lua src/logging/nginx.lua
|
||||
ROOT_LUAS= src\logging.lua
|
||||
|
||||
build clean:
|
||||
|
||||
install:
|
||||
IF NOT EXIST $(LUA_DIR)\logging mkdir $(LUA_DIR)\logging
|
||||
FOR %i IN ($(LUAS)) DO copy %i $(LUA_DIR)\logging
|
||||
FOR %i IN ($(ROOT_LUAS)) DO copy %i $(LUA_DIR)
|
||||
59
deps/src/lualogging/README.md
vendored
Normal file
59
deps/src/lualogging/README.md
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
[](https://github.com/lunarmodules/lualogging/actions?query=workflow%3Atest)
|
||||
|
||||
LuaLogging
|
||||
==========
|
||||
https://lunarmodules.github.io/lualogging/
|
||||
|
||||
LuaLogging provides a simple API to use logging features in Lua.
|
||||
Its design was based on log4j. LuaLogging currently supports,
|
||||
through the use of appenders, console, file, rolling file, email, socket and sql outputs.
|
||||
|
||||
LuaLogging is free software and uses the same license as Lua. It is part of the Kepler Project.
|
||||
|
||||
Please see docs at https://lunarmodules.github.io/lualogging/ for more details
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
With LuaRocks:
|
||||
|
||||
```sh
|
||||
luarocks install lualogging
|
||||
```
|
||||
|
||||
Latest Git revision
|
||||
-------------------
|
||||
|
||||
With LuaRocks:
|
||||
|
||||
```sh
|
||||
luarocks install https://github.com/lunarmodules/lualogging/raw/master/lualogging-dev-1.rockspec
|
||||
```
|
||||
|
||||
With make:
|
||||
|
||||
```sh
|
||||
sudo make
|
||||
```
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
See [LICENSE file](https://github.com/lunarmodules/lualogging/blob/master/COPYRIGHT)
|
||||
|
||||
History and changelog
|
||||
=====================
|
||||
|
||||
For the changelog see the [online documentation](https://lunarmodules.github.io/lualogging/index.html#history).
|
||||
|
||||
### Releasing a new version
|
||||
|
||||
- update changelog in docs (`index.html`, update `history` and `status` sections)
|
||||
- update version in `logging.lua`
|
||||
- update copyright years if needed
|
||||
- update rockspec
|
||||
- commit as `release X.Y.Z`
|
||||
- tag as `vX.Y.Z`
|
||||
- push commit and tag
|
||||
- upload to luarocks
|
||||
- test luarocks installation
|
||||
145
deps/src/lualogging/docs/console.html
vendored
Normal file
145
deps/src/lualogging/docs/console.html
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><strong>Console</strong></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Console appender</h2>
|
||||
|
||||
<p>Console is the simplest appender. It just writes the log messages
|
||||
to <code>io.stdout</code> or <code>io.stderr</code>.</p>
|
||||
|
||||
<pre class="example">
|
||||
function logging.console {
|
||||
[destination = "stdout"|"stderr",]
|
||||
|
||||
[logPattern = <i>string</i>,]
|
||||
[logPatterns = {
|
||||
[logging.DEBUG = <i>string</i>,]
|
||||
[logging.INFO = <i>string</i>,]
|
||||
[logging.WARN = <i>string</i>,]
|
||||
[logging.ERROR = <i>string</i>,]
|
||||
[logging.FATAL = <i>string</i>,]
|
||||
},]
|
||||
[timestampPattern = <i>string</i>,]
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>logPatterns</code>:<br />
|
||||
A table with logPattern strings indexed by the log-levels.
|
||||
A logPattern specifies how the message is written.<br />
|
||||
If this parameter is omitted, a patterns table will be created with the
|
||||
parameter <code>logPattern</code> as the default value for each log-level.
|
||||
If <code>logPattern</code> also is omitted then each level will fall back to
|
||||
the current default setting, see <code>logging.defaultLogPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>logPattern</code>:<br />
|
||||
This value will be used as the default value for each log-level that was
|
||||
omitted in <code>logPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>timestampPattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date/time formatting
|
||||
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
|
||||
|
||||
<li><code>destination</code>:<br />
|
||||
The destination stream, optional. The value can be either <code>"stdout"</code>,
|
||||
or <code>"stderr"</code>. The default is <code>stdout</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h2>Examples</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.console"
|
||||
|
||||
local logger = logging.console()
|
||||
|
||||
logger:info("logging.console test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
209
deps/src/lualogging/docs/doc.css
vendored
Normal file
209
deps/src/lualogging/docs/doc.css
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
body {
|
||||
color: #47555c;
|
||||
font-size: 16px;
|
||||
font-family: "Open Sans", sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #eff4ff;
|
||||
}
|
||||
|
||||
a:link { color: #008fee; }
|
||||
a:visited { color: #008fee; }
|
||||
a:hover { color: #22a7ff; }
|
||||
|
||||
h1 { font-size:26px; }
|
||||
h2 { font-size:24px; }
|
||||
h3 { font-size:18px; }
|
||||
h4 { font-size:16px; }
|
||||
|
||||
hr {
|
||||
height: 1px;
|
||||
background: #c1cce4;
|
||||
border: 0px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: "Open Sans Mono", "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
tt {
|
||||
font-family: "Open Sans Mono", "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
body, td, th {
|
||||
}
|
||||
|
||||
textarea, pre, tt {
|
||||
font-family: "Open Sans Mono", "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
img {
|
||||
border-width: 0px;
|
||||
}
|
||||
|
||||
.example {
|
||||
background-color: #323744;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
padding: 16px 24px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
div.header, div.footer {
|
||||
}
|
||||
|
||||
#container {
|
||||
}
|
||||
|
||||
#product {
|
||||
background-color: white;
|
||||
padding: 10px;
|
||||
height: 130px;
|
||||
border-bottom: solid #d3dbec 1px;
|
||||
}
|
||||
|
||||
#product big {
|
||||
font-size: 42px;
|
||||
}
|
||||
#product strong {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#product_logo {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#product_name {
|
||||
padding-top: 15px;
|
||||
padding-left: 30px;
|
||||
font-size: 42px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#product_description {
|
||||
padding-left: 30px;
|
||||
color: #757779;
|
||||
}
|
||||
|
||||
#main {
|
||||
background: #eff4ff;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
width: 100%;
|
||||
background-color: rgb(44,62,103);
|
||||
padding: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#navigation h1 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#navigation a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#navigation ul li a {
|
||||
color: rgb(136, 208, 255);
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#navigation ul li li a {
|
||||
color: rgb(136, 208, 255);
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#navigation ul {
|
||||
display: inline;
|
||||
color: white;
|
||||
padding: 0px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
padding: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#navigation li li {
|
||||
}
|
||||
|
||||
#navigation li:hover a {
|
||||
color: rgb(166, 238, 255);
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 20px;
|
||||
width: 800px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#about {
|
||||
display: none;
|
||||
}
|
||||
|
||||
dl.reference {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
border: solid #d3dbec 1px;
|
||||
}
|
||||
|
||||
dl.reference dt {
|
||||
padding: 5px;
|
||||
padding-top: 25px;
|
||||
color: #637bbc;
|
||||
}
|
||||
|
||||
dl.reference dl dt {
|
||||
padding-top: 5px;
|
||||
color: #637383;
|
||||
}
|
||||
|
||||
dl.reference dd {
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
font: 10pt "Times New Roman", "TimeNR", Times, serif;
|
||||
}
|
||||
a {
|
||||
font-weight:bold; color: #004080; text-decoration: underline;
|
||||
}
|
||||
#main {
|
||||
background-color: #ffffff; border-left: 0px;
|
||||
}
|
||||
#container {
|
||||
margin-left: 2%; margin-right: 2%; background-color: #ffffff;
|
||||
}
|
||||
#content {
|
||||
margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff;
|
||||
}
|
||||
#navigation {
|
||||
display: none;
|
||||
}
|
||||
#product_logo {
|
||||
display: none;
|
||||
}
|
||||
#about img {
|
||||
display: none;
|
||||
}
|
||||
.example {
|
||||
font-family: "Andale Mono", monospace;
|
||||
font-size: 8pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
177
deps/src/lualogging/docs/email.html
vendored
Normal file
177
deps/src/lualogging/docs/email.html
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><strong>Email</strong></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Email appender</h2>
|
||||
|
||||
<p>This appender can be used to send log requests through email. One email
|
||||
message is sent for each log request.</p>
|
||||
|
||||
<pre class="example">
|
||||
function logging.email {
|
||||
from = <i>string</i>,
|
||||
rcpt = <i>string</i> or <i>string-table</i>,
|
||||
[user = <i>string</i>,]
|
||||
[password = <i>string</i>,]
|
||||
[server = <i>string</i>,]
|
||||
[port = <i>number</i>,]
|
||||
[domain = <i>string</i>,]
|
||||
[headers = <i>table</i>,]
|
||||
|
||||
[logPattern = <i>string</i>,]
|
||||
[logPatterns = {
|
||||
[logging.DEBUG = <i>string</i>,]
|
||||
[logging.INFO = <i>string</i>,]
|
||||
[logging.WARN = <i>string</i>,]
|
||||
[logging.ERROR = <i>string</i>,]
|
||||
[logging.FATAL = <i>string</i>,]
|
||||
},]
|
||||
[timestampPattern = <i>string</i>,]
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>from</code>:<br />
|
||||
The sender of the email message.</li>
|
||||
|
||||
<li><code>rcpt</code>:<br />
|
||||
The recipient of the email message. A string or a numerically indexed Lua table with strings.</li>
|
||||
|
||||
<li><code>user</code>:<br />
|
||||
User for authentication.</li>
|
||||
|
||||
<li><code>password</code>:<br />
|
||||
Password for authentication.</li>
|
||||
|
||||
<li><code>server</code>:<br />
|
||||
Server to connect to. Default is <code>"localhost"</code>.</li>
|
||||
|
||||
<li><code>port</code>:<br />
|
||||
Port to connect to. Default is <code>25</code>.</li>
|
||||
|
||||
<li><code>domain</code>:<br />
|
||||
Domain name used to greet the server. Defaults to the local
|
||||
machine host name.</li>
|
||||
|
||||
<li><code>headers.to</code>:<br />
|
||||
The recipient of the message, as an extended description.</li>
|
||||
|
||||
<li><code>headers.from</code>:<br />
|
||||
The sender of the message, as an extended description.</li>
|
||||
|
||||
<li><code>headers.subject</code>:<br />
|
||||
The subject of the message sent. This can contain patterns like
|
||||
the <code>logPattern</code> parameter.</li>
|
||||
|
||||
<li><code>logPatterns</code>:<br />
|
||||
A table with logPattern strings indexed by the log-levels.
|
||||
A logPattern specifies how the message is written.<br />
|
||||
If this parameter is omitted, a patterns table will be created with the
|
||||
parameter <code>logPattern</code> as the default value for each log-level.
|
||||
If <code>logPattern</code> also is omitted then each level will fall back to
|
||||
the current default setting, see <code>logging.defaultLogPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>logPattern</code>:<br />
|
||||
This value will be used as the default value for each log-level that was
|
||||
omitted in <code>logPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>timestampPattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date/time formatting
|
||||
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.email"
|
||||
|
||||
local logger = logging.email {
|
||||
rcpt = "mail@host.com",
|
||||
from = "mail@host.com",
|
||||
headers = {
|
||||
subject = "[%level] logging.email test",
|
||||
},
|
||||
}
|
||||
|
||||
logger:info("logging.email test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
156
deps/src/lualogging/docs/file.html
vendored
Normal file
156
deps/src/lualogging/docs/file.html
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><strong>File</strong></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>File appender</h2>
|
||||
|
||||
<p>The file appender can be used to write log messages to a file. It
|
||||
uses Lua I/O routines to do its job.</p>
|
||||
|
||||
<pre class="example">
|
||||
function logging.file {
|
||||
[filename = <i>string</i>,]
|
||||
[datePattern = <i>string</i>,]
|
||||
|
||||
[logPattern = <i>string</i>,]
|
||||
[logPatterns = {
|
||||
[logging.DEBUG = <i>string</i>,]
|
||||
[logging.INFO = <i>string</i>,]
|
||||
[logging.WARN = <i>string</i>,]
|
||||
[logging.ERROR = <i>string</i>,]
|
||||
[logging.FATAL = <i>string</i>,]
|
||||
},]
|
||||
[timestampPattern = <i>string</i>,]
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>filename</code>:<br />
|
||||
The name of the file to be written to. On each call to log a
|
||||
message the file is opened for appending and closed immediately.<br />
|
||||
If the file cannot be opened for appending the logging request
|
||||
returns nil and an error message.<br />
|
||||
The default value is <code>"lualogging.log"</code>.</li>
|
||||
|
||||
<li><code>datePattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date
|
||||
pattern that will be passed to the
|
||||
<a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.date"><code>os.date</code></a>
|
||||
function to compose the filename.<br />
|
||||
This is useful to create daily or monthly log files. If the user
|
||||
wants to create one log file per day he specifies a
|
||||
<code>"%Y-%m-%d"</code> pattern and a filename like
|
||||
<code>"temp%s.log"</code>.</li>
|
||||
|
||||
<li><code>logPatterns</code>:<br />
|
||||
A table with logPattern strings indexed by the log-levels.
|
||||
A logPattern specifies how the message is written.<br />
|
||||
If this parameter is omitted, a patterns table will be created with the
|
||||
parameter <code>logPattern</code> as the default value for each log-level.
|
||||
If <code>logPattern</code> also is omitted then each level will fall back to
|
||||
the current default setting, see <code>logging.defaultLogPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>logPattern</code>:<br />
|
||||
This value will be used as the default value for each log-level that was
|
||||
omitted in <code>logPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>timestampPattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date/time formatting
|
||||
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.file"
|
||||
|
||||
local logger = logging.file {
|
||||
filename = "test%s.log",
|
||||
datePattern = "%Y-%m-%d",
|
||||
}
|
||||
|
||||
logger:info("logging.file test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
BIN
deps/src/lualogging/docs/images/lualogging-128.png
vendored
Normal file
BIN
deps/src/lualogging/docs/images/lualogging-128.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
216
deps/src/lualogging/docs/index.html
vendored
Normal file
216
deps/src/lualogging/docs/index.html
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><strong>Home</strong>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
<h2><a name="overview"></a>Overview</h2>
|
||||
|
||||
<p>LuaLogging provides a simple API to use logging features in Lua.
|
||||
Its design was based on
|
||||
<a href="https://logging.apache.org/log4j/docs/index.html">log4j</a>.
|
||||
LuaLogging currently supports, through the use of <em><a href="manual.html#appenders">appenders</a></em>,
|
||||
console, file, email, socket and sql outputs.</p>
|
||||
|
||||
<p>
|
||||
LuaLogging is free software and uses the same <a href="license.html">license</a>
|
||||
as Lua 5.1.
|
||||
</p>
|
||||
|
||||
<h2><a name="status"></a>Status</h2>
|
||||
|
||||
<p>
|
||||
Current version is 1.6.0. It was developed for Lua 5.1+.
|
||||
</p>
|
||||
|
||||
<h2><a name="download"></a>Download</h2>
|
||||
|
||||
<p>
|
||||
LuaLogging can be downloaded from its
|
||||
<a href="https://github.com/lunarmodules/lualogging/archives/master">GitHub</a>
|
||||
downloads page or installed via LuaRocks.
|
||||
</p>
|
||||
|
||||
<h2><a name="dependencies"></a>Dependencies</h2>
|
||||
|
||||
<p>LuaLogging dependencies can be separated by the used appenders:</p>
|
||||
|
||||
<dl>
|
||||
<dt><strong>LuaLogging Core, Console and File appenders</strong></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li><a href="https://www.lua.org">Lua 5.1+</a></li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt><strong>Socket and Email appenders</strong></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li><a href="http://w3.impa.br/~diego/software/luasocket/">LuaSocket</a></li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt><strong>SQL appender</strong></dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>LuaSQL 2.1.x</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h2><a name="history"></a>History</h2>
|
||||
|
||||
<dl class="history">
|
||||
<dt><strong>1.6.0</strong> [09/Nov/2021]</dt>
|
||||
<dd><strong>Added</strong>: the <code>logPattern</code> can now be specified for each log-level individually.
|
||||
This allows use cases like only adding <code>"%source"</code> on debug level, or injecting ansi-color coding
|
||||
in for example the error log-level.</dd>
|
||||
<dd><strong>Added</strong>: new bundled appender; "nginx". This logger has no configuration options, but will
|
||||
simply pass any log messages on to the nginx log. When using LuaLogging in OpenResty, configure this logger.</dd>
|
||||
<dd><strong>Added</strong>: application level defaults. New functions <code>logging.defaultLogPatterns()</code>
|
||||
, <code>logging.defaultTimestampPattern()</code>, <code>logging.defaultLevel()</code>, and <code>logging.defaultLogger()</code>
|
||||
can be used to get/set the global application level defaults.</br>
|
||||
Use carefully, this is global state, so only applications should set those, libraries should not.</dd>
|
||||
<dd><strong>Added</strong>: the included appenders now have an extra parameter to set
|
||||
log-level upon creation; <code>logLevel</code>.</dd>
|
||||
<dd><strong>Added</strong>: the <code>logPattern</code> can now have new placeholders:</br>
|
||||
<code>"%file"</code> (source file), </br>
|
||||
<code>"%line"</code> (source line), </br>
|
||||
<code>"%function"</code> (function name), and </br>
|
||||
<code>"%source"</code> (evaluates to <code>"%file:%line in function '%function'"</code>).</dd>
|
||||
<dd><strong>Added</strong>: the console logger has a new optional parameter "destination",
|
||||
which must be either "stderr" or "stdout" (defaults to "stdout")</dd>
|
||||
|
||||
<dt><strong>1.5.2</strong> [12/Aug/2021]</dt>
|
||||
<dd><strong>Fix</strong>: rolling-file, 'seek' can occasionally fail, handle it properly.</dd>
|
||||
|
||||
<dt><strong>1.5.1</strong> [22/Mar/2021]</dt>
|
||||
<dd><strong>Reverted</strong>: Functionality to specify custom log levels.</dd>
|
||||
|
||||
<dt><strong>1.5.0</strong> [22/Mar/2021]</dt>
|
||||
<dd><strong>Added</strong>: Functionality to specify custom log levels.</dd>
|
||||
<dd><strong>Added</strong>: Provide verbose error message when formatting fails.</dd>
|
||||
<dd><strong>Fix</strong>: disable buffering on windows files</dd>
|
||||
|
||||
<dt><strong>1.4.0</strong> [12/Aug/2020]</dt>
|
||||
<dd><strong>Fix</strong>: No more global on Lua 5.3.</dd>
|
||||
<dd><strong>Fix</strong>: Reduced log noise when changing log levels.</dd>
|
||||
<dd><strong>Added</strong>: A new log-level "off" to suspend logging.</dd>
|
||||
<dd><strong>Fix</strong>: Restored the log-level constants on the logger object.</dd>
|
||||
<dd><strong>Fix</strong>: catch exceptions when formatting log messages.</dd>
|
||||
<dd><strong>Change</strong>: creating loggers now always takes a parameters table (consistent
|
||||
across all appenders). The old parameters are now deprecated, but still
|
||||
work for backward compatibility purposes.</dd>
|
||||
<dd><strong>Added</strong>: All appenders have a new property <code>timestampPattern</code>
|
||||
to specify the format of the timestamp in the log message</dd>
|
||||
<dd><strong>Added</strong>: <code>logger:getPrint()</code> function that returns a print-like
|
||||
function, but directs all output to the logger.</dd>
|
||||
|
||||
<dt><strong>1.3.0</strong> [5/Mar/2013]</dt>
|
||||
|
||||
<dt><strong>1.2.0</strong> [20/Apr/2011]</dt>
|
||||
<dd>Improved performance of logging.</dd>
|
||||
<dd>Added Rolling File Appender.</dd>
|
||||
|
||||
<dt><strong>1.1.4</strong> [30/Oct/2007]</dt>
|
||||
<dd>Fixed bug #1719 -
|
||||
inefficient handling of file loggers (Patch by Jürgen Hötzel).</dd>
|
||||
|
||||
<dt><strong>1.1.3</strong> [08/Aug/2007]</dt>
|
||||
<dd>New makefile for Windows (using nmake) and configure script for Unix.</dd>
|
||||
|
||||
<dt><strong>1.1.2</strong> [14/Aug/2006]</dt>
|
||||
<dd>Fixed a bug found by Carlos Augusto where tostring() was being
|
||||
incorrectly used with numbers.</dd>
|
||||
|
||||
<dt><strong>1.1.1</strong> [31/Mar/2006]</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt><strong>1.1.0</strong> [12/Nov/2004]</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt><strong>1.0.0</strong> [02/Jul/2004]</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
<h2><a name="credits"></a>Credits</h2>
|
||||
|
||||
<p>
|
||||
LuaLogging 1.2 and 1.3 were maintained by Robert G. Jakabosky.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
LuaLogging 1.1.x was designed by Danilo Tuler and Thiago Ponte
|
||||
and implemented by Thiago Ponte.
|
||||
</p>
|
||||
|
||||
<p>LuaLogging 1.0.0 was designed by Danilo Tuler (and log4j)
|
||||
and implemented by Danilo Tuler and André Carregal.</p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
126
deps/src/lualogging/docs/license.html
vendored
Normal file
126
deps/src/lualogging/docs/license.html
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>License</h2>
|
||||
|
||||
<p>
|
||||
LuaLogging is free software: it can be used for both academic and
|
||||
commercial purposes at absolutely no cost. There are no royalties
|
||||
or GNU-like "copyleft" restrictions. LuaLogging qualifies as <a
|
||||
href="https://www.opensource.org/docs/definition.html">Open
|
||||
Source</a> software. Its licenses are compatible with <a href=
|
||||
"https://www.gnu.org/licenses/gpl.html">GPL</a>. LuaLogging is not
|
||||
in the public domain and the Kepler Project keep its copyright. The
|
||||
legal details are below.
|
||||
</p>
|
||||
|
||||
<p>The spirit of the license is that you are free to use LuaLogging
|
||||
for any purpose at no cost without having to ask us. The only
|
||||
requirement is that if you do use LuaLogging, then you should give
|
||||
us credit by including the appropriate copyright notice somewhere
|
||||
in your product or its documentation.</p>
|
||||
|
||||
<p>The LuaLogging library is designed by Danilo Tuler and
|
||||
implemented by Danilo Tuler, Thiago Ponte and André
|
||||
Carregal. The implementation is not derived from licensed
|
||||
software.</p>
|
||||
|
||||
<hr/>
|
||||
<p>
|
||||
Copyright © 2004-2021 Kepler Project.
|
||||
</p>
|
||||
|
||||
<p>Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:</p>
|
||||
|
||||
<p>The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.</p>
|
||||
|
||||
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.</p>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
391
deps/src/lualogging/docs/manual.html
vendored
Normal file
391
deps/src/lualogging/docs/manual.html
vendored
Normal file
@@ -0,0 +1,391 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Manual</strong>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2><a name="introduction"></a>Introduction</h2>
|
||||
|
||||
<p>LuaLogging provides a simple API to use logging features in Lua.
|
||||
Its design was based on
|
||||
<a href="https://logging.apache.org/log4j/docs/index.html">log4j</a>.
|
||||
LuaLogging currently supports console, file, email, socket and sql
|
||||
outputs through the use of <em><a href="#appenders">appenders</a></em>.</p>
|
||||
|
||||
<p>The <code>logging</code> module holds a <code>new</code> function to create
|
||||
new <a href="#logger"><code>logger</code></a> objects.</p>
|
||||
|
||||
<p>This logger constructor receives a function
|
||||
(known as the <em>appender</em> function)
|
||||
that will be called on each call to log a message.</p>
|
||||
|
||||
<p>An <em>appender</em> function receives three arguments:</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>self</strong>: the logger object</li>
|
||||
<li><strong>level</strong>: the logging level</li>
|
||||
<li><strong>message</strong>: the message to be logged</li>
|
||||
</ul>
|
||||
<p>The logger constructor also receives a optional second argument which should
|
||||
be a table with parameters</p>
|
||||
|
||||
<h2><a name="installation"></a>Installation</h2>
|
||||
|
||||
<p>LuaLogging is installed as a regular Lua module called <code>logging</code>.</p>
|
||||
<p>installation is easiest using LuaRocks; "<code>luarocks install lualogging</code>",
|
||||
or alternatively using the <code>Makefile</code>.</p>
|
||||
|
||||
<h2><a name="logging"></a>Logging module</h2>
|
||||
|
||||
<p>The logging module has a number of global functions:</p>
|
||||
<dl class="reference">
|
||||
<dt><strong>logging.new( function[, logLevel] )</strong></dt>
|
||||
<dd>Creates a new logger object from a custom 'appender' function. See examples below.
|
||||
The appender function signature is <code>function(self, level, message)</code>. The
|
||||
optional logLevel argument specifies the initial log-level to set (the value must be
|
||||
a valid log-level constant). If omitted defaults to <code>logging.defaultLevel</code>.
|
||||
</dd>
|
||||
|
||||
<dt><strong>patts = logging.buildLogPatterns([table], [string])</strong></dt>
|
||||
<dd>Creates a log-patterns table. The returned table will for each level have
|
||||
the logPattern set to 1. the value in the table, or alternatively 2. the
|
||||
string value, or 3. the pattern from the global defaults.</br>
|
||||
</br>
|
||||
Returns a logPatterns table.</br>
|
||||
</br>
|
||||
Example logging source info only on debug-level, and coloring error and fatal
|
||||
messages:
|
||||
<pre class="example">
|
||||
local patterns = logging.buildLogPatterns(
|
||||
{
|
||||
[logging.DEBUG] = "%date %level %message (%source)\n"
|
||||
[logging.ERROR] = "%date "..ansi_red.."%level %message"..ansi_reset.."\n"
|
||||
[logging.FATAL] = "%date "..ansi_red.."%level %message"..ansi_reset.."\n"
|
||||
}, "%date %level %message\n"
|
||||
)
|
||||
</pre>
|
||||
</dd>
|
||||
|
||||
<dt><strong>patts = logging.defaultLogPatterns([string | table])</strong></dt>
|
||||
<dd>Sets the default logPatterns (global!) if a parameter is given.
|
||||
If the parameter is a string then that string will be used as the pattern for
|
||||
all log-levels. If a table is given, then it must have all log-levels defined
|
||||
with a pattern string. See also <code>logging.buildLogPatterns</code>.</br>
|
||||
</br>
|
||||
The default is <code>"%date %level %message\n"</code> for all log-levels.</br>
|
||||
</br>
|
||||
Available placeholders in the pattern string are; <code>"%date"</code>, <code>"%level"</code>, <code>"%message"</code>,
|
||||
<code>"%file"</code>, <code>"%line"</code>, <code>"%function"</code> and <code>"%source"</code>. The <code>"%source"</code> placeholder evaluates
|
||||
to <code>"%file:%line in function'%function'"</code>.</br>
|
||||
</br>
|
||||
Returns the current defaultLogPatterns value.</br>
|
||||
</br>
|
||||
<em>NOTE:</em> since this is a global setting, libraries should never set it,
|
||||
only applications should.
|
||||
</dd>
|
||||
|
||||
<dt><strong>patt = logging.defaultTimestampPattern([string])</strong></dt>
|
||||
<dd>Sets the default timestampPattern (global!) if given.
|
||||
The default is <code>nil</code>, which results in a system specific date/time format.
|
||||
The pattern should be accepted by the Lua function
|
||||
<a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.date"><code>os.date</code></a> for formatting.</br>
|
||||
</br>
|
||||
Returns the current defaultTimestampPattern value.</br>
|
||||
</br>
|
||||
<em>NOTE:</em> since this is a global setting, libraries should never set it,
|
||||
only applications should.
|
||||
</dd>
|
||||
|
||||
<dt><strong>level = logging.defaultLevel([level constant])</strong></dt>
|
||||
<dd>Sets the default log-level (global!) if given. Each new logger object created
|
||||
will start with the log-level as specified by this value.
|
||||
The level parameter must be one of the log-level constants. The default is <code>logging.DEBUG</code>.</br>
|
||||
</br>
|
||||
Returns the current defaultLevel value.</br>
|
||||
</br>
|
||||
<em>NOTE:</em> since this is a global setting, libraries should never set it,
|
||||
only applications should.
|
||||
</dd>
|
||||
|
||||
<dt><strong>logger = logging.defaultLogger([logger object])</strong></dt>
|
||||
<dd>Sets the default logger object (global!) if given.
|
||||
The logger parameter must be a LuaLogging logger object. The default is to
|
||||
generate a new <code>console</code> logger (with "destination" set to "stderr")
|
||||
on the first call to get the default logger.</br>
|
||||
</br>
|
||||
Returns the current defaultLogger value.</br>
|
||||
</br>
|
||||
<em>NOTE:</em> since this is a global setting, libraries should never set it,
|
||||
only applications should. Libraries should get this logger and use it, assuming
|
||||
the application has set it.
|
||||
<pre class="example">
|
||||
-- Example: application setting the default logger
|
||||
local color = require("ansicolors") -- https://github.com/kikito/ansicolors.lua
|
||||
local ll = require("logging")
|
||||
require "logging.console"
|
||||
ll.defaultLogger(ll.console {
|
||||
destination = "stderr",
|
||||
timestampPattern = "!%y-%m-%dT%H:%M:%SZ", -- ISO 8601 in UTC
|
||||
logPatterns = {
|
||||
[ll.DEBUG] = color("%{white}%date%{cyan} %level %message (%source)\n"),
|
||||
[ll.INFO] = color("%{white}%date%{white} %level %message\n"),
|
||||
[ll.WARN] = color("%{white}%date%{yellow} %level %message\n"),
|
||||
[ll.ERROR] = color("%{white}%date%{red bright} %level %message %{cyan}(%source)\n"),
|
||||
[ll.FATAL] = color("%{white}%date%{magenta bright} %level %message %{cyan}(%source)\n"),
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Example: library using default if available (fallback to nop)
|
||||
local log do
|
||||
local ll = package.loaded.logging
|
||||
if ll and type(ll) == "table" and ll.defaultLogger and
|
||||
tostring(ll._VERSION):find("LuaLogging") then
|
||||
-- default LuaLogging logger is available
|
||||
log = ll.defaultLogger()
|
||||
else
|
||||
-- just use a stub logger with only no-op functions
|
||||
local nop = function() end
|
||||
log = setmetatable({}, {
|
||||
__index = function(self, key) self[key] = nop return nop end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
log:debug("starting my library")
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h2><a name="logger"></a>Logger objects</h2>
|
||||
|
||||
<p>Logger objects are created by loading the 'appender' module, and calling on it. For example:</p>
|
||||
<pre class="example">
|
||||
local logger = require("logging.console") {
|
||||
-- options go here (see appenders for options)
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>A logger object offers the following methods that write log messages.</p>
|
||||
|
||||
<p>For each of the methods below, the parameter <code>message</code> may be any lua value,
|
||||
not only strings. When necessary <code>message</code> is converted to a string.</p>
|
||||
|
||||
<p>The parameter <code>level</code> can be one of the variables enumerated below.
|
||||
The values are presented in descending criticality, so if the minimum level is
|
||||
defined as <code>logger.WARN</code> then <code>logger.INFO</code> and
|
||||
<code>logger.DEBUG</code> level messages are not logged.
|
||||
The default set level at startup is <code>logger.DEBUG</code>.</p>
|
||||
|
||||
<h3>Constants</h3>
|
||||
|
||||
<dl class="reference">
|
||||
<dt><strong>logger.DEBUG</strong></dt>
|
||||
<dd>The <em>DEBUG</em> level designates fine-grained informational events that
|
||||
are most useful to debug an application.</dd>
|
||||
|
||||
<dt><strong>logger.INFO</strong></dt>
|
||||
<dd>The <em>INFO</em> level designates informational messages that highlight the
|
||||
progress of the application at coarse-grained level.</dd>
|
||||
|
||||
<dt><strong>logger.WARN</strong></dt>
|
||||
<dd>The <em>WARN</em> level designates potentially harmful situations.</dd>
|
||||
|
||||
<dt><strong>logger.ERROR</strong></dt>
|
||||
<dd>The <em>ERROR</em> level designates error events that might still allow the
|
||||
application to continue running.</dd>
|
||||
|
||||
<dt><strong>logger.FATAL</strong></dt>
|
||||
<dd>The <em>FATAL</em> level designates very severe error events that would
|
||||
presumably lead the application to abort.</dd>
|
||||
|
||||
<dt><strong>logger.OFF</strong></dt>
|
||||
<dd>The <em>OFF</em> level will stop all log messages.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Methods</h3>
|
||||
|
||||
<dl class="reference">
|
||||
<dt><strong>logger:log (level, [message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with the specified level.</dd>
|
||||
|
||||
<dt><strong>logger:setLevel (level)</strong></dt>
|
||||
<dd>This method sets a minimum level for messages to be logged.</dd>
|
||||
|
||||
<dt><strong>logger:getPrint (level)</strong></dt>
|
||||
<dd>This method returns a print-like function that redirects all output to
|
||||
the logger instead of the console. The <code>level</code> parameter specifies
|
||||
the log-level of the output.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The following set of methods is dynamically generated from the log-levels.</p>
|
||||
|
||||
<dl class="reference">
|
||||
|
||||
<dt><strong>logger:debug ([message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with DEBUG level.</dd>
|
||||
|
||||
<dt><strong>logger:info ([message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with INFO level.</dd>
|
||||
|
||||
<dt><strong>logger:warn ([message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with WARN level.</dd>
|
||||
|
||||
<dt><strong>logger:error ([message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with ERROR level.</dd>
|
||||
|
||||
<dt><strong>logger:fatal ([message]|[table]|[format, ...]|[function, ...])</strong></dt>
|
||||
<dd>Logs a message with FATAL level.</dd>
|
||||
</dl>
|
||||
|
||||
<h2><a name="examples"></a>Examples</h2>
|
||||
|
||||
<p>The example below creates a logger that prints the level and message
|
||||
to the standard output (or whatever the print function does).</p>
|
||||
|
||||
<pre class="example">
|
||||
local Logging = require "logging"
|
||||
|
||||
local appender = function(self, level, message)
|
||||
print(level, message)
|
||||
return true
|
||||
end
|
||||
|
||||
local logger = Logging.new(appender)
|
||||
|
||||
logger:setLevel(logger.WARN)
|
||||
logger:log(logger.INFO, "sending email")
|
||||
|
||||
logger:info("trying to contact server")
|
||||
logger:warn("server did not respond yet")
|
||||
logger:error("server unreachable")
|
||||
|
||||
-- dump a table in a log message
|
||||
local tab = { a = 1, b = 2 }
|
||||
logger:debug(tab)
|
||||
|
||||
-- use string.format() style formatting
|
||||
logger:info("val1='%s', val2=%d", "string value", 1234)
|
||||
|
||||
-- complex log formatting.
|
||||
local function log_callback(val1, val2)
|
||||
-- Do some complex pre-processing of parameters, maybe dump a table to a string.
|
||||
return string.format("val1='%s', val2=%d", val1, val2)
|
||||
end
|
||||
|
||||
-- function 'log_callback' will only be called if the current log level is "DEBUG"
|
||||
logger:debug(log_callback, "string value", 1234)
|
||||
|
||||
-- create a print that redirects to the logger at level "INFO"
|
||||
logger:setLevel (logger.INFO)
|
||||
local print = logger:getPrint(logger.INFO)
|
||||
print "hello\nthere!"
|
||||
</pre>
|
||||
|
||||
<p>Upon execution of the above example the following lines will
|
||||
show in the standard output. Notice that some of the <em>INFO</em> log requests
|
||||
are not handled because the minimum level is set to <em>WARN</em>.</p>
|
||||
|
||||
<pre class="example">
|
||||
WARN server did not responded yet
|
||||
ERROR server unreachable
|
||||
INFO hello
|
||||
INFO there!
|
||||
</pre>
|
||||
|
||||
<a name="appenders"></a>
|
||||
|
||||
<h2>Appenders</h2>
|
||||
|
||||
The following appenders are included in the standard distribution.
|
||||
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx/OpenResty</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Upgrading from 1.0.0</h2>
|
||||
|
||||
<p>Upgrading from LuaLogging 1.0.0 is very easy. The
|
||||
<code>logger</code> object is fully compatible. You just need to
|
||||
change the code that creates the object.</p>
|
||||
|
||||
<p>The <code>logger</code> constructor from 1.0.0 received a single
|
||||
argument which was a filename. To upgrade to 1.1.0 you should
|
||||
create a <code>logging.file</code> object instead, passing the
|
||||
filename as argument. As simple as this.</p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
108
deps/src/lualogging/docs/nginx.html
vendored
Normal file
108
deps/src/lualogging/docs/nginx.html
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><strong>Nginx</strong></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Nginx/Openresty appender</h2>
|
||||
|
||||
<p>This appender has no configuration options, and simply forwards whatever is
|
||||
being logged to the configured Nginx log. LuaLogging log-levels will be converted
|
||||
to the equivalent Nginx ones, and initial log-level will be set to match the
|
||||
Nginx system level.</p>
|
||||
<p>It makes sense to configure this logger and set it as the default logger on
|
||||
Nginx/OpenResty startup. Any libraries will then be able to just grab the
|
||||
defaultLogger from <code>logging.defaultLogger()</code> and won't need any
|
||||
modifications to work with Nginx/OpenResty.</p>
|
||||
|
||||
<h2>Examples</h2>
|
||||
|
||||
<pre class="example">
|
||||
require("logging.nginx")
|
||||
local logging = require("logging")
|
||||
|
||||
local logger = logging.nginx()
|
||||
logging.defaultLogger(logger)
|
||||
|
||||
logger:info("logging.nginx test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
161
deps/src/lualogging/docs/rolling_file.html
vendored
Normal file
161
deps/src/lualogging/docs/rolling_file.html
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><strong>Rolling File</strong></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Rolling File appender</h2>
|
||||
|
||||
<p>The rolling file appender can be used to write log messages to a file. It
|
||||
uses Lua I/O routines to do its job. The rolling file appender rolls over the logfile
|
||||
once it has reached a certain size limit. It also mantains a maximum number of log files.</p>
|
||||
|
||||
<pre class="example">
|
||||
function logging.rolling_file {
|
||||
[filename = <i>string</i>,]
|
||||
maxFileSize = <i>number</i>,
|
||||
[maxBackupIndex = <i>number</i>,]
|
||||
|
||||
[logPattern = <i>string</i>,]
|
||||
[logPatterns = {
|
||||
[logging.DEBUG = <i>string</i>,]
|
||||
[logging.INFO = <i>string</i>,]
|
||||
[logging.WARN = <i>string</i>,]
|
||||
[logging.ERROR = <i>string</i>,]
|
||||
[logging.FATAL = <i>string</i>,]
|
||||
},]
|
||||
[timestampPattern = <i>string</i>,]
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>filename</code>:<br />
|
||||
The name of the file to be written to.<br />
|
||||
If the file cannot be opened for appending the logging request
|
||||
returns nil and an error message.<br />
|
||||
The default value is <code>"lualogging.log"</code>.</li>
|
||||
|
||||
<li><code>maxFileSize</code>:<br />
|
||||
The max size of the file in bytes. Every time the file reaches this size
|
||||
it will rollover, generating a new clean log file and storing the old log
|
||||
on a filename.n, where n goes from 1 to the configured maxBackupIndex.<br />
|
||||
The more recent backup is the one with the lowest n on its filename.<br />
|
||||
Eg. test.log.1 (most recent backup) <br />
|
||||
test.log.2 (least recent backup)
|
||||
</li>
|
||||
|
||||
<li><code>maxBackupIndex</code>:<br />
|
||||
The number of backup files that will be generated.
|
||||
The default value is <code>1</code>.</li>
|
||||
|
||||
<li><code>logPatterns</code>:<br />
|
||||
A table with logPattern strings indexed by the log-levels.
|
||||
A logPattern specifies how the message is written.<br />
|
||||
If this parameter is omitted, a patterns table will be created with the
|
||||
parameter <code>logPattern</code> as the default value for each log-level.
|
||||
If <code>logPattern</code> also is omitted then each level will fall back to
|
||||
the current default setting, see <code>logging.defaultLogPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>logPattern</code>:<br />
|
||||
This value will be used as the default value for each log-level that was
|
||||
omitted in <code>logPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>timestampPattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date/time formatting
|
||||
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.rolling_file"
|
||||
|
||||
local logger = logging.rolling_file {
|
||||
filename = "test.log",
|
||||
maxFileSize = 1024,
|
||||
maxBackupIndex = 5,
|
||||
}
|
||||
|
||||
logger:info("logging.rolling_file test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
152
deps/src/lualogging/docs/socket.html
vendored
Normal file
152
deps/src/lualogging/docs/socket.html
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><a href="sql.html">SQL</a></li>
|
||||
<li><strong>Socket</strong></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Socket appender</h2>
|
||||
|
||||
This appender can be used to send log requests through a socket.
|
||||
Socket appender relies on <a href=
|
||||
"https://www.tecgraf.puc-rio.br/luasocket">LuaSocket</a> to do its
|
||||
job.<br />
|
||||
Upon each log request a connection is opened, the message is sent
|
||||
and the connection is closed.
|
||||
|
||||
<pre class="example">
|
||||
function logging.socket {
|
||||
hostname = <i>string</i>,
|
||||
port = <i>number</i>,
|
||||
|
||||
[logPattern = <i>string</i>,]
|
||||
[logPatterns = {
|
||||
[logging.DEBUG = <i>string</i>,]
|
||||
[logging.INFO = <i>string</i>,]
|
||||
[logging.WARN = <i>string</i>,]
|
||||
[logging.ERROR = <i>string</i>,]
|
||||
[logging.FATAL = <i>string</i>,]
|
||||
},]
|
||||
[timestampPattern = <i>string</i>,]
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>hostname</code>:<br />
|
||||
Hostname can be an IP address or a host name of the server where the log
|
||||
message will be sent.</li>
|
||||
|
||||
<li><code>port</code>:<br />
|
||||
The port must be an integer number in the range [1..64K).</li>
|
||||
|
||||
<li><code>logPatterns</code>:<br />
|
||||
A table with logPattern strings indexed by the log-levels.
|
||||
A logPattern specifies how the message is written.<br />
|
||||
If this parameter is omitted, a patterns table will be created with the
|
||||
parameter <code>logPattern</code> as the default value for each log-level.
|
||||
If <code>logPattern</code> also is omitted then each level will fall back to
|
||||
the current default setting, see <code>logging.defaultLogPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>logPattern</code>:<br />
|
||||
This value will be used as the default value for each log-level that was
|
||||
omitted in <code>logPatterns</code>.
|
||||
</li>
|
||||
|
||||
<li><code>timestampPattern</code>:<br />
|
||||
This is an optional parameter that can be used to specify a date/time formatting
|
||||
in the log message. The default is taken from <code>logging.defaultTimestampPattern()</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.socket"
|
||||
|
||||
local logger = logging.socket {
|
||||
hostname = "localhost",
|
||||
port = 5000,
|
||||
}
|
||||
|
||||
logger:info("logging.socket test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
149
deps/src/lualogging/docs/sql.html
vendored
Normal file
149
deps/src/lualogging/docs/sql.html
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>LuaLogging: A simple API to use logging features in Lua</title>
|
||||
<link rel="stylesheet" href="doc.css" type="text/css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo">
|
||||
<img alt="LuaLogging logo" src="images/lualogging-128.png"/>
|
||||
</div>
|
||||
<div id="product_name"><big><strong>LuaLogging</strong></big></div>
|
||||
<div id="product_description">A simple API to use logging features in Lua.</div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
<div id="main">
|
||||
|
||||
<div id="navigation">
|
||||
<h1>LuaLogging</h1>
|
||||
<ul>
|
||||
<li><a href="index.html">Home</a>
|
||||
<ul>
|
||||
<li><a href="index.html#download">Download</a></li>
|
||||
<li><a href="index.html#dependencies">Dependencies</a></li>
|
||||
<li><a href="index.html#history">History</a></li>
|
||||
<li><a href="index.html#credits">Credits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html">Manual</a>
|
||||
<ul>
|
||||
<li><a href="manual.html#installation">Installation</a></li>
|
||||
<li><a href="manual.html#logger">Logger objects</a></li>
|
||||
<li><a href="manual.html#examples">Examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="manual.html#appenders">Appenders</a>
|
||||
<ul>
|
||||
<li><a href="console.html">Console</a></li>
|
||||
<li><a href="file.html">File</a></li>
|
||||
<li><a href="rolling_file.html">Rolling File</a></li>
|
||||
<li><strong>SQL</strong></li>
|
||||
<li><a href="socket.html">Socket</a></li>
|
||||
<li><a href="email.html">Email</a></li>
|
||||
<li><a href="nginx.html">Nginx</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging">Project</a>
|
||||
<ul>
|
||||
<li><a href="https://github.com/lunarmodules/lualogging/issues">Bug Tracker</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="license.html">License</a></li>
|
||||
</ul>
|
||||
</div> <!-- id="navigation" -->
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>SQL appender</h2>
|
||||
|
||||
<p>The SQL appender can be used to write log messages to a SQL
|
||||
database table. It uses <a href="https://keplerproject.github.io/luasql/">LuaSQL</a>,
|
||||
therefore any database supported by LuaSQL can be used.</p>
|
||||
|
||||
<pre class="example">
|
||||
function logging.sql{
|
||||
connectionfactory = <i>function</i>,
|
||||
[tablename = <i>string</i>,]
|
||||
[logdatefield = <i>string</i>,]
|
||||
[loglevelfield = <i>string</i>,]
|
||||
[logmessagefield = <i>string</i>,]
|
||||
[keepalive = <i>boolean</i>,]
|
||||
|
||||
[logLevel = <i>log-level-constant</i>,]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<ul>
|
||||
<li><code>connectionfactory</code>:<br />
|
||||
This must be a function that creates a LuaSQL connection object.
|
||||
This function will be called everytime a connection needs to be
|
||||
created.</li>
|
||||
|
||||
<li><code>tablename</code>:<br />
|
||||
The name of the table to write the log requests. Default value is
|
||||
<code>"LogTable"</code>.</li>
|
||||
|
||||
<li><code>logdatefield</code>:<br />
|
||||
The name of the field to write the date of each log request.
|
||||
Default value is <code>"LogDate"</code>.</li>
|
||||
|
||||
<li><code>loglevelfield</code>:<br />
|
||||
The name of the field to write the level of each log request.
|
||||
Default value is <code>"LogLevel"</code>.</li>
|
||||
|
||||
<li><code>logmessagefield</code>:<br />
|
||||
The name of the field to write the message of each log request.
|
||||
Default value is <code>"LogMessage"</code>.</li>
|
||||
|
||||
<li><code>keepalive</code>:<br />
|
||||
In every log request a connection to the database is opened, the
|
||||
message is written, and the connection is closed.<br />
|
||||
If the user wants to keep the connection opened he can specify
|
||||
<code>keepalive = true</code>.</li>
|
||||
|
||||
<li><code>logLevel</code>:<br />
|
||||
The initial log-level to set for the created logger.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<pre class="example">
|
||||
require"logging.sql"
|
||||
require"luasql.jdbc"
|
||||
|
||||
local env, err = luasql.jdbc('com.mysql.jdbc.Driver')
|
||||
|
||||
local logger = logging.sql {
|
||||
connectionfactory = function()
|
||||
local con, err = env:connect('jdbc:mysql://localhost/test',
|
||||
'tcp', '123')
|
||||
assert(con, err)
|
||||
return con
|
||||
end,
|
||||
keepalive = true,
|
||||
}
|
||||
|
||||
logger:info("logging.sql test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
</pre>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
|
||||
</div> <!-- id="main" -->
|
||||
|
||||
<div id="about">
|
||||
<p><a href="https://validator.w3.org/check?uri=referer">
|
||||
<img src="https://www.w3.org/Icons/valid-xhtml10" alt="XHTML 1.0 válido!" height="31" width="88" /></a></p>
|
||||
</div> <!-- id="about" -->
|
||||
|
||||
</div> <!-- id="container" -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
44
deps/src/lualogging/lualogging-dev-2.rockspec
vendored
Normal file
44
deps/src/lualogging/lualogging-dev-2.rockspec
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
local package_name = "lualogging"
|
||||
local package_version = "dev"
|
||||
local rockspec_revision = "2"
|
||||
local github_account_name = "lunarmodules"
|
||||
local github_repo_name = package_name
|
||||
|
||||
|
||||
package = package_name
|
||||
version = package_version.."-"..rockspec_revision
|
||||
source = {
|
||||
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
|
||||
branch = "master"
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
['logging.nginx'] = "src/logging/nginx.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
36
deps/src/lualogging/rockspecs/lualogging-1.2.0-2.rockspec
vendored
Normal file
36
deps/src/lualogging/rockspecs/lualogging-1.2.0-2.rockspec
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package = "lualogging"
|
||||
version = "1.2.0-2"
|
||||
source = {
|
||||
url = "git://github.com/lunarmodules/lualogging.git",
|
||||
branch = "v1.2.0",
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/lunarmodules/lualogging",
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"doc/html",
|
||||
},
|
||||
}
|
||||
36
deps/src/lualogging/rockspecs/lualogging-1.3.0-2.rockspec
vendored
Normal file
36
deps/src/lualogging/rockspecs/lualogging-1.3.0-2.rockspec
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package = "lualogging"
|
||||
version = "1.3.0-2"
|
||||
source = {
|
||||
url = "git://github.com/lunarmodules/lualogging.git",
|
||||
branch = "v1.3.0",
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/lunarmodules/lualogging",
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"doc/html",
|
||||
},
|
||||
}
|
||||
36
deps/src/lualogging/rockspecs/lualogging-1.4.0-1.rockspec
vendored
Normal file
36
deps/src/lualogging/rockspecs/lualogging-1.4.0-1.rockspec
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package = "lualogging"
|
||||
version = "1.4.0-1"
|
||||
source = {
|
||||
url = "git://github.com/lunarmodules/lualogging.git",
|
||||
branch = "v1.4.0",
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/lunarmodules/lualogging",
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
43
deps/src/lualogging/rockspecs/lualogging-1.5.0-1.rockspec
vendored
Normal file
43
deps/src/lualogging/rockspecs/lualogging-1.5.0-1.rockspec
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
local package_name = "lualogging"
|
||||
local package_version = "1.5.0"
|
||||
local rockspec_revision = "1"
|
||||
local github_account_name = "lunarmodules"
|
||||
local github_repo_name = package_name
|
||||
|
||||
|
||||
package = package_name
|
||||
version = package_version.."-"..rockspec_revision
|
||||
source = {
|
||||
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
|
||||
tag = "v"..package_version
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
43
deps/src/lualogging/rockspecs/lualogging-1.5.1-1.rockspec
vendored
Normal file
43
deps/src/lualogging/rockspecs/lualogging-1.5.1-1.rockspec
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
local package_name = "lualogging"
|
||||
local package_version = "1.5.1"
|
||||
local rockspec_revision = "1"
|
||||
local github_account_name = "lunarmodules"
|
||||
local github_repo_name = package_name
|
||||
|
||||
|
||||
package = package_name
|
||||
version = package_version.."-"..rockspec_revision
|
||||
source = {
|
||||
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
|
||||
tag = "v"..package_version
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
43
deps/src/lualogging/rockspecs/lualogging-1.5.2-1.rockspec
vendored
Normal file
43
deps/src/lualogging/rockspecs/lualogging-1.5.2-1.rockspec
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
local package_name = "lualogging"
|
||||
local package_version = "1.5.2"
|
||||
local rockspec_revision = "1"
|
||||
local github_account_name = "lunarmodules"
|
||||
local github_repo_name = package_name
|
||||
|
||||
|
||||
package = package_name
|
||||
version = package_version.."-"..rockspec_revision
|
||||
source = {
|
||||
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
|
||||
tag = "v"..package_version
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
44
deps/src/lualogging/rockspecs/lualogging-1.6.0-1.rockspec
vendored
Normal file
44
deps/src/lualogging/rockspecs/lualogging-1.6.0-1.rockspec
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
local package_name = "lualogging"
|
||||
local package_version = "1.6.0"
|
||||
local rockspec_revision = "1"
|
||||
local github_account_name = "lunarmodules"
|
||||
local github_repo_name = package_name
|
||||
|
||||
|
||||
package = package_name
|
||||
version = package_version.."-"..rockspec_revision
|
||||
source = {
|
||||
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
|
||||
branch = "master"
|
||||
}
|
||||
description = {
|
||||
summary = "A simple API to use logging features",
|
||||
detailed = [[
|
||||
LuaLogging provides a simple API to use logging features in Lua. Its design was
|
||||
based on log4j. LuaLogging currently supports, through the use of appenders,
|
||||
console, file, rolling file, email, socket and SQL outputs.
|
||||
]],
|
||||
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name,
|
||||
license = "MIT/X11",
|
||||
}
|
||||
dependencies = {
|
||||
"luasocket"
|
||||
}
|
||||
build = {
|
||||
type = "none",
|
||||
install = {
|
||||
lua = {
|
||||
['logging'] = "src/logging.lua",
|
||||
['logging.console'] = "src/logging/console.lua",
|
||||
['logging.file'] = "src/logging/file.lua",
|
||||
['logging.rolling_file'] = "src/logging/rolling_file.lua",
|
||||
['logging.email'] = "src/logging/email.lua",
|
||||
['logging.sql'] = "src/logging/sql.lua",
|
||||
['logging.socket'] = "src/logging/socket.lua",
|
||||
['logging.nginx'] = "src/logging/nginx.lua",
|
||||
}
|
||||
},
|
||||
copy_directories = {
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
415
deps/src/lualogging/src/logging.lua
vendored
Normal file
415
deps/src/lualogging/src/logging.lua
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- includes a new tostring function that handles tables recursively
|
||||
--
|
||||
-- @author Danilo Tuler (tuler@ideais.com.br)
|
||||
-- @author Andre Carregal (info@keplerproject.org)
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local type, table, string, _tostring, tonumber = type, table, string, tostring, tonumber
|
||||
local select = select
|
||||
local error = error
|
||||
local format = string.format
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
|
||||
local logging = {
|
||||
-- Meta information
|
||||
_COPYRIGHT = "Copyright (C) 2004-2021 Kepler Project",
|
||||
_DESCRIPTION = "A simple API to use logging features in Lua",
|
||||
_VERSION = "LuaLogging 1.6.0",
|
||||
}
|
||||
|
||||
local LEVELS = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF" }
|
||||
local MAX_LEVELS = #LEVELS
|
||||
for i, level in ipairs(LEVELS) do
|
||||
LEVELS[level] = i
|
||||
logging[level] = level
|
||||
end
|
||||
|
||||
local defaultLevel = LEVELS[1]
|
||||
local defaultLogPattern = "%date %level %message\n"
|
||||
local defaultLogPatterns = nil
|
||||
local defaultTimestampPattern = nil
|
||||
local defaultLogger = nil
|
||||
|
||||
local function rewrite_stacktrace()
|
||||
-- prettify stack-trace, remove lualogging entries and reformat to 1 line
|
||||
local result = ''
|
||||
local trace = debug.traceback()
|
||||
for entry in trace:gmatch("%s*(.-)\n") do
|
||||
if entry:match("%:%d+%:") and not entry:find('logging.lua') then
|
||||
result = result .. ' | ' .. entry
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- private log function, with support for formating a complex log message.
|
||||
local function LOG_MSG(self, level, fmt, ...)
|
||||
local f_type = type(fmt)
|
||||
if f_type == 'string' then
|
||||
if select('#', ...) > 0 then
|
||||
local status, msg = pcall(format, fmt, ...)
|
||||
if status then
|
||||
return self:append(level, msg)
|
||||
else
|
||||
return self:append(level, "Error formatting log message: " ..
|
||||
msg .. rewrite_stacktrace())
|
||||
end
|
||||
else
|
||||
-- only a single string, no formating needed.
|
||||
return self:append(level, fmt)
|
||||
end
|
||||
elseif f_type == 'function' then
|
||||
-- fmt should be a callable function which returns the message to log
|
||||
return self:append(level, fmt(...))
|
||||
end
|
||||
-- fmt is not a string and not a function, just call tostring() on it.
|
||||
return self:append(level, logging.tostring(fmt))
|
||||
end
|
||||
|
||||
-- do nothing function for disabled levels.
|
||||
local function disable_level() end
|
||||
|
||||
-- a generic print function that prints to the log
|
||||
local function print_to_log(logger, level, ...)
|
||||
local args = { n = select("#", ...), ... }
|
||||
for i = 1, args.n do args[i] = _tostring(args[i]) end
|
||||
args = table.concat(args, " ") .. "\n"
|
||||
for line in args:gmatch("(.-)\n") do
|
||||
logger:log(level, line)
|
||||
end
|
||||
end
|
||||
|
||||
-- improved assertion function.
|
||||
local function assert(exp, ...)
|
||||
-- if exp is true, we are finished so don't do any processing of the parameters
|
||||
if exp then return exp, ... end
|
||||
-- assertion failed, raise error
|
||||
error(format(...), 2)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Creates a new logger object
|
||||
-- @param append Function used by the logger to append a message with a
|
||||
-- log-level to the log stream.
|
||||
-- @param startLevel log-level to start with
|
||||
-- @return Table representing the new logger object.
|
||||
-- @return String if there was any error setting the custom levels if provided
|
||||
-------------------------------------------------------------------------------
|
||||
function logging.new(append, startLevel)
|
||||
assert(type(append) == "function", "Appender must be a function, got: %s.", type(append))
|
||||
startLevel = startLevel or defaultLevel
|
||||
assert(LEVELS[startLevel], "startLevel must be a valid log-level constant if given")
|
||||
|
||||
local LEVEL_FUNCS = {}
|
||||
|
||||
local logger = {}
|
||||
logger.append = append
|
||||
|
||||
logger.setLevel = function (self, level)
|
||||
local order = LEVELS[level]
|
||||
assert(order, "undefined level '%s'", _tostring(level))
|
||||
local old_level = self.level
|
||||
self.level = level
|
||||
self.level_order = order
|
||||
-- enable/disable levels
|
||||
for i=1, MAX_LEVELS do
|
||||
local name = LEVELS[i]:lower()
|
||||
if i >= order and i ~= MAX_LEVELS then
|
||||
self[name] = LEVEL_FUNCS[i]
|
||||
else
|
||||
self[name] = disable_level
|
||||
end
|
||||
end
|
||||
if old_level and old_level ~= level then
|
||||
self:log(LEVELS[1], "Logger: changing loglevel from %s to %s", old_level, level)
|
||||
end
|
||||
end
|
||||
|
||||
-- generic log function.
|
||||
logger.log = function (self, level, ...)
|
||||
local order = LEVELS[level]
|
||||
assert(order, "undefined level `%s'", _tostring(level))
|
||||
if order < self.level_order then
|
||||
return
|
||||
end
|
||||
return LOG_MSG(self, level, ...)
|
||||
end
|
||||
|
||||
-- a print function generator
|
||||
logger.getPrint = function (self, level)
|
||||
local order = LEVELS[level]
|
||||
assert(order, "undefined level `%s'", _tostring(level))
|
||||
return function(...)
|
||||
if order >= self.level_order then
|
||||
print_to_log(self, level, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- create the proxy functions for each log level.
|
||||
for i=1, MAX_LEVELS do
|
||||
local level = LEVELS[i]
|
||||
if logger[level:lower()] then
|
||||
return nil, "'" .. level .."' is not a proper level name since there is already a property '" .. level:lower() .. "'"
|
||||
end
|
||||
LEVEL_FUNCS[i] = function(self, ...)
|
||||
-- no level checking needed here, this function will only be called if it's level is active.
|
||||
return LOG_MSG(self, level, ...)
|
||||
end
|
||||
end
|
||||
|
||||
-- insert log level constants
|
||||
for i=1, MAX_LEVELS do
|
||||
logger[LEVELS[i]] = LEVELS[i]
|
||||
end
|
||||
|
||||
-- initialize log level.
|
||||
logger:setLevel(startLevel)
|
||||
return logger
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Prepares the log message
|
||||
-------------------------------------------------------------------------------
|
||||
local sourceDebugLevel = 1 -- this will be set dynamically below
|
||||
local getDebugInfoLine = "local info = debug.getinfo(%d)"
|
||||
|
||||
function logging.compilePattern(pattern)
|
||||
pattern = string.format("%q", pattern)
|
||||
|
||||
-- replace %source by its components first
|
||||
pattern = pattern:gsub("%%source", "%%file:%%line in function '%%function'")
|
||||
|
||||
local placeholders = {
|
||||
["date"] = false,
|
||||
["level"] = false,
|
||||
["message"] = false,
|
||||
-- truthy: requires debug info to be fetched first
|
||||
["file"] = "info.short_src",
|
||||
["line"] = "info.currentline",
|
||||
["function"] = '(info.name or "unknown function")',
|
||||
}
|
||||
local inject_info = false
|
||||
for placeholder, needs_info in pairs(placeholders) do
|
||||
local count
|
||||
pattern, count = pattern:gsub("%%"..placeholder, '"..'..(needs_info or placeholder)..'.."')
|
||||
inject_info = inject_info or (count>0 and needs_info)
|
||||
end
|
||||
-- cleanup start & end
|
||||
if pattern:sub(1, 4) == '""..' then
|
||||
pattern = pattern:sub(5, -1)
|
||||
end
|
||||
if pattern:sub(-4, -1) == '..""' then
|
||||
pattern = pattern:sub(1, -5)
|
||||
end
|
||||
-- build function
|
||||
local func = [[
|
||||
return function(date, level, message)
|
||||
]]..(inject_info and getDebugInfoLine:format(sourceDebugLevel) or "")..[[
|
||||
|
||||
return ]]..pattern..[[
|
||||
|
||||
end]]
|
||||
|
||||
return (loadstring or load)(func, "lualogging_generated_formatter")()
|
||||
end
|
||||
|
||||
local clearCompiledCache
|
||||
do
|
||||
local cache = setmetatable({}, {
|
||||
__index = function(self, pattern)
|
||||
-- pattern wasn't found in cache, compile now, and cache format-function
|
||||
self[pattern] = logging.compilePattern(pattern)
|
||||
return self[pattern]
|
||||
end
|
||||
})
|
||||
|
||||
function clearCompiledCache()
|
||||
for k in pairs(cache) do cache[k] = nil end
|
||||
end
|
||||
|
||||
function logging.prepareLogMsg(lpattern, dpattern, level, message)
|
||||
return cache[lpattern](dpattern, level, message)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Converts a Lua value to a string
|
||||
--
|
||||
-- Converts Table fields in alphabetical order
|
||||
-------------------------------------------------------------------------------
|
||||
local function tostring(value)
|
||||
local str = ''
|
||||
|
||||
if (type(value) ~= 'table') then
|
||||
if (type(value) == 'string') then
|
||||
str = string.format("%q", value)
|
||||
else
|
||||
str = _tostring(value)
|
||||
end
|
||||
else
|
||||
local auxTable = {}
|
||||
for key in pairs(value) do
|
||||
if (tonumber(key) ~= key) then
|
||||
table.insert(auxTable, key)
|
||||
else
|
||||
table.insert(auxTable, tostring(key))
|
||||
end
|
||||
end
|
||||
table.sort(auxTable)
|
||||
|
||||
str = str..'{'
|
||||
local separator = ""
|
||||
local entry
|
||||
for _, fieldName in ipairs(auxTable) do
|
||||
if ((tonumber(fieldName)) and (tonumber(fieldName) > 0)) then
|
||||
entry = tostring(value[tonumber(fieldName)])
|
||||
else
|
||||
entry = fieldName.." = "..tostring(value[fieldName])
|
||||
end
|
||||
str = str..separator..entry
|
||||
separator = ", "
|
||||
end
|
||||
str = str..'}'
|
||||
end
|
||||
return str
|
||||
end
|
||||
logging.tostring = tostring
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Application level defaults
|
||||
-------------------------------------------------------------------------------
|
||||
function logging.defaultLogPatterns(patt)
|
||||
if patt then
|
||||
if type(patt) == "string" then
|
||||
patt = logging.buildLogPatterns({}, patt)
|
||||
end
|
||||
assert(type(patt) == "table", "logPatterns must be a string or a table, got: %s", type(patt))
|
||||
for _, level in ipairs(LEVELS) do
|
||||
if level ~= "OFF" then
|
||||
assert(type(patt[level]) == "string", "the patterns contains a '%s' value (instead of a string) for level '%s'", type(patt[level]), level)
|
||||
end
|
||||
end
|
||||
defaultLogPatterns = patt
|
||||
end
|
||||
return defaultLogPatterns
|
||||
end
|
||||
|
||||
function logging.defaultTimestampPattern(patt)
|
||||
if patt then
|
||||
if type(patt) ~= "string" then
|
||||
error("timestampPattern must be a string", 2)
|
||||
end
|
||||
defaultTimestampPattern = patt
|
||||
end
|
||||
return defaultTimestampPattern
|
||||
end
|
||||
|
||||
function logging.defaultLevel(level)
|
||||
if level then
|
||||
if not LEVELS[level] then
|
||||
assert(LEVELS[level], "undefined level '%s'", _tostring(level))
|
||||
end
|
||||
defaultLevel = level
|
||||
end
|
||||
return defaultLevel
|
||||
end
|
||||
|
||||
function logging.defaultLogger(logger)
|
||||
if logger then
|
||||
-- check getPrint to protect against accidental call using colon-notation
|
||||
if type(logger) ~= "table" or type(logger.getPrint) ~= "function" then
|
||||
error("expected a logger object", 2)
|
||||
end
|
||||
defaultLogger = logger
|
||||
end
|
||||
|
||||
if not defaultLogger then
|
||||
-- no default logger yet, go create it, using the current defaults
|
||||
defaultLogger = require("logging.console") { destination = "stderr" }
|
||||
end
|
||||
|
||||
return defaultLogger
|
||||
end
|
||||
|
||||
--- Returns a table of patterns, indexed by loglevel.
|
||||
-- @param patterns (table, optional) table containing logPattern strings per level, defaults to `{}`
|
||||
-- @param default (string, optional) the logPattern to be used for levels not yet present in 'patterns'.
|
||||
-- @return table, with a logPattern for every log-level constant
|
||||
function logging.buildLogPatterns(patterns, default)
|
||||
patterns = patterns or {}
|
||||
assert(type(default) == "string" or type(default) == "nil", "expected default logPattern (2nd argument) to be a string or nil, got: %s", tostring(default))
|
||||
assert(type(patterns) == "table", "expected patterns (1st argument) to be a table or nil, got: %s", tostring(patterns))
|
||||
local target = {}
|
||||
for _, level in ipairs(LEVELS) do
|
||||
if level ~= "OFF" then
|
||||
target[level] = patterns[level] or default or defaultLogPatterns[level]
|
||||
end
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
defaultLogPatterns = logging.buildLogPatterns({}, defaultLogPattern)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Backward compatible parameter handling
|
||||
-------------------------------------------------------------------------------
|
||||
function logging.getDeprecatedParams(lst, ...) -- TODO: remove in next major version
|
||||
local args = { n = select("#", ...), ...}
|
||||
if type(args[1]) == "table" then
|
||||
-- this is the new format of a single params-table
|
||||
return args[1]
|
||||
end
|
||||
|
||||
local params = {}
|
||||
for i, param_name in ipairs(lst) do
|
||||
params[param_name] = args[i]
|
||||
end
|
||||
return params
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- dynamically detect proper source debug level, since this can vary by Lua versions
|
||||
-------------------------------------------------------------------------------
|
||||
do
|
||||
local detection_logger, test_msg
|
||||
|
||||
local function detect_func() detection_logger:debug("message") end -- This function MUST be on a single line!!
|
||||
local detect_func_info = debug.getinfo(detect_func)
|
||||
local detect_func_match = detect_func_info.short_src..":"..tostring(detect_func_info.linedefined or -999)
|
||||
|
||||
detection_logger = logging.new( function(self, level, message)
|
||||
test_msg = logging.prepareLogMsg("%source", "", level, message)
|
||||
end)
|
||||
|
||||
while true do
|
||||
if not pcall(detect_func) then
|
||||
-- cannot detect debug level, so set the function to fetch debug info to
|
||||
-- return a table that always returns "na" for each lookup
|
||||
getDebugInfoLine = "local info = setmetatable({}, { __index = function() return 'na' end })"
|
||||
break
|
||||
end
|
||||
|
||||
if test_msg:find(detect_func_match, 1, true) then
|
||||
break -- found correct level, done
|
||||
end
|
||||
-- move to next level
|
||||
sourceDebugLevel = sourceDebugLevel + 1
|
||||
clearCompiledCache()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if _VERSION < 'Lua 5.2' then
|
||||
-- still create 'logging' global for Lua versions < 5.2
|
||||
_G.logging = logging
|
||||
end
|
||||
|
||||
return logging
|
||||
41
deps/src/lualogging/src/logging/console.lua
vendored
Normal file
41
deps/src/lualogging/src/logging/console.lua
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Prints logging information to console
|
||||
--
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local io = require"io"
|
||||
local logging = require"logging"
|
||||
local prepareLogMsg = logging.prepareLogMsg
|
||||
|
||||
local destinations = setmetatable({
|
||||
stdout = "stdout",
|
||||
stderr = "stderr",
|
||||
},
|
||||
{
|
||||
__index = function(self, key)
|
||||
if not key then
|
||||
return "stdout" -- default value
|
||||
end
|
||||
error("destination parameter must be either 'stderr' or 'stdout', got: "..tostring(key), 3)
|
||||
end
|
||||
})
|
||||
|
||||
function logging.console(params, ...)
|
||||
params = logging.getDeprecatedParams({ "logPattern" }, params, ...)
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
local destination = destinations[params.destination]
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
io[destination]:write(prepareLogMsg(logPatterns[level], os.date(timestampPattern), level, message))
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.console
|
||||
|
||||
48
deps/src/lualogging/src/logging/email.lua
vendored
Normal file
48
deps/src/lualogging/src/logging/email.lua
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Emails logging information to the given recipient
|
||||
--
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local logging = require"logging"
|
||||
local smtp = require"socket.smtp"
|
||||
|
||||
function logging.email(params)
|
||||
params = params or {}
|
||||
params.headers = params.headers or {}
|
||||
|
||||
if params.from == nil then
|
||||
return nil, "'from' parameter is required"
|
||||
end
|
||||
if params.rcpt == nil then
|
||||
return nil, "'rcpt' parameter is required"
|
||||
end
|
||||
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
local dt = os.date(timestampPattern)
|
||||
local s = logging.prepareLogMsg(logPatterns[level], dt, level, message)
|
||||
if params.headers.subject then
|
||||
params.headers.subject =
|
||||
logging.prepareLogMsg(params.headers.subject, dt, level, message)
|
||||
end
|
||||
local msg = { headers = params.headers, body = s }
|
||||
params.source = smtp.message(msg)
|
||||
|
||||
local r, e = smtp.send(params)
|
||||
if not r then
|
||||
return nil, e
|
||||
end
|
||||
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.email
|
||||
|
||||
68
deps/src/lualogging/src/logging/file.lua
vendored
Normal file
68
deps/src/lualogging/src/logging/file.lua
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Saves logging information in a file
|
||||
--
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local logging = require"logging"
|
||||
|
||||
local lastFileNameDatePattern
|
||||
local lastFileHandler
|
||||
|
||||
local buffer_mode do
|
||||
local dir_separator = _G.package.config:sub(1,1)
|
||||
local is_windows = dir_separator == '\\'
|
||||
if is_windows then
|
||||
-- Windows does not support "line" buffered mode, see
|
||||
-- https://github.com/lunarmodules/lualogging/pull/9
|
||||
buffer_mode = "no"
|
||||
else
|
||||
buffer_mode = "line"
|
||||
end
|
||||
end
|
||||
|
||||
local openFileLogger = function (filename, datePattern)
|
||||
local filename = string.format(filename, os.date(datePattern))
|
||||
if (lastFileNameDatePattern ~= filename) then
|
||||
local f = io.open(filename, "a")
|
||||
if (f) then
|
||||
f:setvbuf(buffer_mode)
|
||||
lastFileNameDatePattern = filename
|
||||
lastFileHandler = f
|
||||
return f
|
||||
else
|
||||
return nil, string.format("file `%s' could not be opened for writing", filename)
|
||||
end
|
||||
else
|
||||
return lastFileHandler
|
||||
end
|
||||
end
|
||||
|
||||
function logging.file(params, ...)
|
||||
params = logging.getDeprecatedParams({ "filename", "datePattern", "logPattern" }, params, ...)
|
||||
local filename = params.filename
|
||||
local datePattern = params.datePattern
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
|
||||
if type(filename) ~= "string" then
|
||||
filename = "lualogging.log"
|
||||
end
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
local f, msg = openFileLogger(filename, datePattern)
|
||||
if not f then
|
||||
return nil, msg
|
||||
end
|
||||
local s = logging.prepareLogMsg(logPatterns[level], os.date(timestampPattern), level, message)
|
||||
f:write(s)
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.file
|
||||
|
||||
45
deps/src/lualogging/src/logging/nginx.lua
vendored
Normal file
45
deps/src/lualogging/src/logging/nginx.lua
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Forwards logging information to the Nginx log
|
||||
--
|
||||
-- @author Thijs Schreijer
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local logging = require "logging"
|
||||
local prepareLogMsg = logging.prepareLogMsg
|
||||
|
||||
local ngx_log = assert((ngx or {}).log, "this logger can only be used with OpenResty")
|
||||
|
||||
local levels = {
|
||||
[logging.FATAL] = ngx.EMERG,
|
||||
[logging.ERROR] = ngx.ERR,
|
||||
[logging.WARN] = ngx.WARN,
|
||||
[logging.INFO] = ngx.INFO,
|
||||
[logging.DEBUG] = ngx.DEBUG,
|
||||
}
|
||||
|
||||
|
||||
local target_level do
|
||||
-- set the default lualogging level, based on the detected Nginx level
|
||||
local sys_log_level = require("ngx.errlog").get_sys_filter_level()
|
||||
for ll_level, ngx_level in pairs(levels) do
|
||||
if sys_log_level == ngx_level then
|
||||
target_level = ll_level
|
||||
ngx_log(ngx.DEBUG, "setting LuaLogging default level '", ll_level, "' to match Nginx level: ", ngx_level)
|
||||
break
|
||||
end
|
||||
end
|
||||
assert(target_level, "failed to map ngx log-level '"..tostring(sys_log_level).."' to a LuaLogging level")
|
||||
end
|
||||
|
||||
|
||||
function logging.nginx(params)
|
||||
return logging.new(function(self, level, message)
|
||||
return ngx_log(levels[level], prepareLogMsg("%message", "", level, message))
|
||||
end, target_level)
|
||||
end
|
||||
|
||||
|
||||
return logging.nginx
|
||||
97
deps/src/lualogging/src/logging/rolling_file.lua
vendored
Normal file
97
deps/src/lualogging/src/logging/rolling_file.lua
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
---------------------------------------------------------------------------
|
||||
-- RollingFileAppender is a FileAppender that rolls over the logfile
|
||||
-- once it has reached a certain size limit. It also mantains a
|
||||
-- maximum number of log files.
|
||||
--
|
||||
-- @author Tiago Cesar Katcipis (tiagokatcipis@gmail.com)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local logging = require"logging"
|
||||
|
||||
local buffer_mode do
|
||||
local dir_separator = _G.package.config:sub(1,1)
|
||||
local is_windows = dir_separator == '\\'
|
||||
if is_windows then
|
||||
-- Windows does not support "line" buffered mode, see
|
||||
-- https://github.com/lunarmodules/lualogging/pull/9
|
||||
buffer_mode = "no"
|
||||
else
|
||||
buffer_mode = "line"
|
||||
end
|
||||
end
|
||||
|
||||
local function openFile(self)
|
||||
self.file = io.open(self.filename, "a")
|
||||
if not self.file then
|
||||
return nil, string.format("file `%s' could not be opened for writing", self.filename)
|
||||
end
|
||||
self.file:setvbuf(buffer_mode)
|
||||
return self.file
|
||||
end
|
||||
|
||||
local rollOver = function (self)
|
||||
for i = self.maxIndex - 1, 1, -1 do
|
||||
-- files may not exist yet, lets ignore the possible errors.
|
||||
os.rename(self.filename.."."..i, self.filename.."."..i+1)
|
||||
end
|
||||
|
||||
self.file:close()
|
||||
self.file = nil
|
||||
|
||||
local _, msg = os.rename(self.filename, self.filename..".".."1")
|
||||
|
||||
if msg then
|
||||
return nil, string.format("error %s on log rollover", msg)
|
||||
end
|
||||
|
||||
return openFile(self)
|
||||
end
|
||||
|
||||
|
||||
local openRollingFileLogger = function (self)
|
||||
if not self.file then
|
||||
return openFile(self)
|
||||
end
|
||||
|
||||
local filesize = self.file:seek("end", 0)
|
||||
if not filesize then
|
||||
self.file:close()
|
||||
self.file = nil
|
||||
return openFile(self)
|
||||
end
|
||||
|
||||
if (filesize < self.maxSize) then
|
||||
return self.file
|
||||
end
|
||||
|
||||
return rollOver(self)
|
||||
end
|
||||
|
||||
|
||||
function logging.rolling_file(params, ...)
|
||||
params = logging.getDeprecatedParams({ "filename", "maxFileSize", "maxBackupIndex", "logPattern" }, params, ...)
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
|
||||
local obj = {
|
||||
filename = type(params.filename) == "string" and params.filename or "lualogging.log",
|
||||
maxSize = params.maxFileSize,
|
||||
maxIndex = params.maxBackupIndex or 1
|
||||
}
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
local f, msg = openRollingFileLogger(obj)
|
||||
if not f then
|
||||
return nil, msg
|
||||
end
|
||||
local s = logging.prepareLogMsg(logPatterns[level], os.date(timestampPattern), level, message)
|
||||
f:write(s)
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.rolling_file
|
||||
|
||||
40
deps/src/lualogging/src/logging/socket.lua
vendored
Normal file
40
deps/src/lualogging/src/logging/socket.lua
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Sends the logging information through a socket using luasocket
|
||||
--
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local logging = require"logging"
|
||||
local socket = require"socket"
|
||||
|
||||
function logging.socket(params, ...)
|
||||
params = logging.getDeprecatedParams({ "hostname", "port", "logPattern" }, params, ...)
|
||||
local hostname = params.hostname
|
||||
local port = params.port
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
local s = logging.prepareLogMsg(logPatterns[level], os.date(timestampPattern), level, message)
|
||||
|
||||
local socket, err = socket.connect(hostname, port)
|
||||
if not socket then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local cond, err = socket:send(s)
|
||||
if not cond then
|
||||
return nil, err
|
||||
end
|
||||
socket:close()
|
||||
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.socket
|
||||
|
||||
64
deps/src/lualogging/src/logging/sql.lua
vendored
Normal file
64
deps/src/lualogging/src/logging/sql.lua
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- Saves the logging information in a table using luasql
|
||||
--
|
||||
-- @author Thiago Costa Ponte (thiago@ideais.com.br)
|
||||
--
|
||||
-- @copyright 2004-2021 Kepler Project
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local logging = require"logging"
|
||||
|
||||
function logging.sql(params)
|
||||
params = params or {}
|
||||
params.tablename = params.tablename or "LogTable"
|
||||
params.logdatefield = params.logdatefield or "LogDate"
|
||||
params.loglevelfield = params.loglevelfield or "LogLevel"
|
||||
params.logmessagefield = params.logmessagefield or "LogMessage"
|
||||
|
||||
local startLevel = params.logLevel or logging.defaultLevel()
|
||||
|
||||
if params.connectionfactory == nil or type(params.connectionfactory) ~= "function" then
|
||||
return nil, "No specified connection factory function"
|
||||
end
|
||||
|
||||
local con, err
|
||||
if params.keepalive then
|
||||
con, err = params.connectionfactory()
|
||||
end
|
||||
|
||||
return logging.new( function(self, level, message)
|
||||
if (not params.keepalive) or (con == nil) then
|
||||
con, err = params.connectionfactory()
|
||||
if not con then
|
||||
return nil, err
|
||||
end
|
||||
end
|
||||
|
||||
local logDate = os.date("%Y-%m-%d %H:%M:%S")
|
||||
local insert = string.format("INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s')",
|
||||
params.tablename, params.logdatefield, params.loglevelfield,
|
||||
params.logmessagefield, logDate, level, string.gsub(message, "'", "''"))
|
||||
|
||||
local ret = pcall(con.execute, con, insert)
|
||||
if not ret then
|
||||
con, err = params.connectionfactory()
|
||||
if not con then
|
||||
return nil, err
|
||||
end
|
||||
ret, err = con:execute(insert)
|
||||
if not ret then
|
||||
return nil, err
|
||||
end
|
||||
end
|
||||
|
||||
if not params.keepalive then
|
||||
con:close()
|
||||
end
|
||||
|
||||
return true
|
||||
end, startLevel)
|
||||
end
|
||||
|
||||
return logging.sql
|
||||
|
||||
241
deps/src/lualogging/tests/generic.lua
vendored
Normal file
241
deps/src/lualogging/tests/generic.lua
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
local logging = require "logging"
|
||||
local call_count
|
||||
local last_msg
|
||||
local msgs
|
||||
|
||||
function logging.test(params)
|
||||
local logPatterns = logging.buildLogPatterns(params.logPatterns, params.logPattern)
|
||||
local timestampPattern = params.timestampPattern or logging.defaultTimestampPattern()
|
||||
return logging.new( function(self, level, message)
|
||||
last_msg = logging.prepareLogMsg(logPatterns[level], os.date(timestampPattern), level, message)
|
||||
msgs = msgs or {}
|
||||
table.insert(msgs, last_msg)
|
||||
--print("----->",last_msg)
|
||||
call_count = call_count + 1
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
local function reset()
|
||||
call_count = 0
|
||||
last_msg = nil
|
||||
msgs = nil
|
||||
end
|
||||
|
||||
local tests = {}
|
||||
|
||||
|
||||
|
||||
|
||||
tests.constants_for_lualogging = function()
|
||||
local DEFAULT_LEVELS = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF" }
|
||||
for _, level in ipairs(DEFAULT_LEVELS) do
|
||||
assert(logging[level], "constant logging."..level.." is not defined")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tests.deprecated_parameter_handling = function()
|
||||
local list = { "param1", "next_one", "hello_world" }
|
||||
local params = logging.getDeprecatedParams(list, {
|
||||
param1 = 1,
|
||||
next_one = nil,
|
||||
hello_world = 3,
|
||||
})
|
||||
assert(params.param1 == 1)
|
||||
assert(params.next_one == nil)
|
||||
assert(params.hello_world == 3)
|
||||
|
||||
params = logging.getDeprecatedParams(list, 1, nil, 3)
|
||||
assert(params.param1 == 1)
|
||||
assert(params.next_one == nil)
|
||||
assert(params.hello_world == 3)
|
||||
end
|
||||
|
||||
tests.buildLogPatterns = function()
|
||||
local check_patterns = function(t)
|
||||
assert(type(t) == "table")
|
||||
assert(t.DEBUG and t.INFO and t.WARN and t.ERROR and t.FATAL)
|
||||
local i = 0
|
||||
for k,v in pairs(t) do i = i + 1 end
|
||||
assert(i == 5)
|
||||
end
|
||||
local t = logging.buildLogPatterns()
|
||||
check_patterns(t)
|
||||
local t = logging.buildLogPatterns(nil, "hello")
|
||||
check_patterns(t)
|
||||
assert(t.DEBUG == "hello")
|
||||
assert(t.FATAL == "hello")
|
||||
local t = logging.buildLogPatterns({}, "hello")
|
||||
check_patterns(t)
|
||||
assert(t.DEBUG == "hello")
|
||||
assert(t.FATAL == "hello")
|
||||
local t = logging.buildLogPatterns({
|
||||
DEBUG = "bye"
|
||||
}, "hello")
|
||||
check_patterns(t)
|
||||
assert(t.DEBUG == "bye")
|
||||
assert(t.INFO == "hello")
|
||||
assert(t.FATAL == "hello")
|
||||
end
|
||||
|
||||
tests.log_levels = function()
|
||||
local logger = logging.test { logPattern = "%message", timestampPattern = nil }
|
||||
logger:setLevel(logger.DEBUG)
|
||||
-- debug gets logged
|
||||
logger:debug("message 1")
|
||||
assert(last_msg == "message 1", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 1, "Got: " .. tostring(call_count))
|
||||
-- fatal also gets logged at 'debug' setting
|
||||
logger:fatal("message 2")
|
||||
assert(last_msg == "message 2", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 2, "Got: " .. tostring(call_count))
|
||||
|
||||
logger:setLevel(logger.FATAL)
|
||||
-- debug gets logged
|
||||
logger:debug("message 3") -- should not change the last message
|
||||
assert(last_msg == "message 2", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 2, "Got: " .. tostring(call_count))
|
||||
-- fatal also gets logged at 'debug' setting
|
||||
logger:fatal("message 4") -- should be logged as 3rd message
|
||||
assert(last_msg == "message 4", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 3, "Got: " .. tostring(call_count))
|
||||
|
||||
logger:setLevel(logger.OFF)
|
||||
-- debug gets logged
|
||||
logger:debug("message 5") -- should not change the last message
|
||||
assert(last_msg == "message 4", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 3, "Got: " .. tostring(call_count))
|
||||
-- fatal also gets logged at 'debug' setting
|
||||
logger:fatal("message 6") -- should not change the last message
|
||||
assert(last_msg == "message 4", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 3, "Got: " .. tostring(call_count))
|
||||
-- should never log "OFF", even if its set
|
||||
logger:fatal("message 7") -- should not change the last message
|
||||
assert(last_msg == "message 4", "got: " .. tostring(last_msg))
|
||||
assert(call_count == 3, "Got: " .. tostring(call_count))
|
||||
end
|
||||
|
||||
|
||||
tests.logPatterns = function()
|
||||
local logger = logging.test { logPattern = "%date", timestampPattern = nil }
|
||||
logger:debug("hello")
|
||||
assert(last_msg ~= "%date", "expected '%date' placeholder to be replaced, got: " .. tostring(last_msg))
|
||||
assert(last_msg ~= "", "expected '%date' placeholder to be replaced by a value, got an empty string")
|
||||
|
||||
local logger = logging.test { logPattern = "%level", timestampPattern = nil }
|
||||
logger:fatal("hello")
|
||||
assert(last_msg ~= "%level", "expected '%level' placeholder to be replaced, got: " .. tostring(last_msg))
|
||||
assert(last_msg == "FATAL", "expected '%level' placeholder to be replaced by 'FATAL', got: " .. tostring(last_msg))
|
||||
|
||||
local logger = logging.test { logPattern = "%message", timestampPattern = nil }
|
||||
logger:debug("hello")
|
||||
assert(last_msg ~= "%message", "expected '%message' placeholder to be replaced, got: " .. tostring(last_msg))
|
||||
assert(last_msg == "hello", "expected '%message' placeholder to be replaced by 'hello', got: " .. tostring(last_msg))
|
||||
|
||||
local logger = logging.test { logPattern = "%source", timestampPattern = nil }
|
||||
local function test_func()
|
||||
logger:debug("hello")
|
||||
end
|
||||
test_func()
|
||||
assert(last_msg ~= "%source", "expected '%source' placeholder to be replaced, got: " .. tostring(last_msg))
|
||||
assert(last_msg:find("'test_func'", 1, true), "expected function name in output, got: " .. tostring(last_msg))
|
||||
assert(last_msg:find(":138 ", 1, true), "expected line number in output, got: " .. tostring(last_msg)) -- update hardcoded linenumber when this fails!
|
||||
assert(last_msg:find("generic.lua:", 1, true), "expected filename in output, got: " .. tostring(last_msg))
|
||||
|
||||
-- mutiple separate patterns
|
||||
local logger = logging.test {
|
||||
logPattern = "%message",
|
||||
logPatterns = {
|
||||
[logging.DEBUG] = "hello %message"
|
||||
},
|
||||
timestampPattern = nil,
|
||||
}
|
||||
logger:debug("world")
|
||||
assert(last_msg == "hello world", "expected 'hello world', got: " .. tostring(last_msg))
|
||||
logger:error("world")
|
||||
assert(last_msg == "world", "expected 'world', got: " .. tostring(last_msg))
|
||||
end
|
||||
|
||||
|
||||
tests.table_serialization = function()
|
||||
local logger = logging.test { logPattern = "%message", timestampPattern = nil }
|
||||
|
||||
logger:debug({1,2,3,4,5,6,7,8,9,10})
|
||||
assert(last_msg == "{1, 10, 2, 3, 4, 5, 6, 7, 8, 9}", "got: " .. tostring(last_msg))
|
||||
|
||||
logger:debug({abc = "cde", "hello", "world", xyz = true, 1, 2, 3})
|
||||
assert(last_msg == '{"hello", "world", 1, 2, 3, abc = "cde", xyz = true}', "got: " .. tostring(last_msg))
|
||||
end
|
||||
|
||||
|
||||
tests.print_function = function()
|
||||
local logger = logging.test { logPattern = "%level %message" }
|
||||
local print = logger:getPrint(logger.DEBUG)
|
||||
print("hey", "there", "dude")
|
||||
assert(msgs[1] == "DEBUG hey there dude")
|
||||
print()
|
||||
assert(msgs[2] == "DEBUG ")
|
||||
print("hello\nthere")
|
||||
assert(msgs[3] == "DEBUG hello")
|
||||
assert(msgs[4] == "DEBUG there")
|
||||
print({}, true, nil, 0)
|
||||
assert(msgs[5]:find("table"))
|
||||
assert(msgs[5]:find(" true nil 0$"))
|
||||
end
|
||||
|
||||
|
||||
tests.format_error_stacktrace = function()
|
||||
local count = 0
|
||||
local logger = logging.test { logPattern = "%level %message" }
|
||||
|
||||
logger:debug("%s-%s", 'abc', '007')
|
||||
assert(last_msg == 'DEBUG abc-007')
|
||||
|
||||
logger:debug("%s=%s", nil)
|
||||
assert(last_msg:find("bad argument #%d to '(.-)'"))
|
||||
assert(last_msg:find("in main chunk"))
|
||||
assert(last_msg:find("in %w+ 'func'"))
|
||||
local _, levels = last_msg:gsub("(|)", function() count = count + 1 end)
|
||||
assert(levels == 3, "got : " .. levels)
|
||||
end
|
||||
|
||||
|
||||
tests.defaultLogger = function()
|
||||
-- returns a logger
|
||||
assert(logging.defaultLogger(), "expected a logger object to be returned)")
|
||||
local logger = logging.test {}
|
||||
-- setting a default one
|
||||
assert(logging.defaultLogger(logger), "expected a logger object to be returned)")
|
||||
assert(logger == logging.defaultLogger(), "expected my previously set logger to be returned)")
|
||||
end
|
||||
|
||||
|
||||
tests.defaultLevel = function()
|
||||
-- default level is 'debug'
|
||||
local old_level = logging.defaultLevel()
|
||||
assert(old_level == logging.DEBUG, "expected default to be 'debug'")
|
||||
-- setting level
|
||||
assert(logging.defaultLevel(logging.FATAL) == logging.FATAL, "expected updated log-level")
|
||||
-- new logger uses new default level
|
||||
local logger = logging.test {}
|
||||
logger:error("less than 'fatal', should not be logged")
|
||||
assert(call_count == 0)
|
||||
logger:fatal("should be logged")
|
||||
assert(call_count == 1)
|
||||
|
||||
-- errors on unknown level
|
||||
assert(not pcall(logging.defaultLevel, "unknown level"), "expected an error to be thrown")
|
||||
|
||||
-- restore old default
|
||||
logging.defaultLevel(old_level)
|
||||
end
|
||||
|
||||
|
||||
for name, func in pairs(tests) do
|
||||
reset()
|
||||
print("generic test: " .. name)
|
||||
func()
|
||||
end
|
||||
|
||||
print("[v] all generic tests succesful")
|
||||
8
deps/src/lualogging/tests/run_tests.sh
vendored
Executable file
8
deps/src/lualogging/tests/run_tests.sh
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
LUA_PATH="../src/?.lua;$LUA_PATH" lua test.lua
|
||||
|
||||
rm -f test.db test.log*
|
||||
|
||||
17
deps/src/lualogging/tests/test.lua
vendored
Normal file
17
deps/src/lualogging/tests/test.lua
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
local test = {
|
||||
"generic.lua",
|
||||
"testConsole.lua",
|
||||
"testFile.lua",
|
||||
"testMail.lua",
|
||||
"testSocket.lua",
|
||||
"testSQL.lua",
|
||||
"testRollingFile.lua",
|
||||
}
|
||||
|
||||
print ("Start of Logging tests")
|
||||
for _, filename in ipairs(test) do
|
||||
dofile(filename)
|
||||
end
|
||||
print ("End of Logging tests")
|
||||
|
||||
12
deps/src/lualogging/tests/testConsole.lua
vendored
Normal file
12
deps/src/lualogging/tests/testConsole.lua
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
local log_console = require"logging.console"
|
||||
|
||||
local logger = log_console()
|
||||
|
||||
logger:info("logging.console test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
logger:debug("string with %4")
|
||||
logger:setLevel("INFO") -- test log level change warning.
|
||||
|
||||
print("Console Logging OK")
|
||||
|
||||
81
deps/src/lualogging/tests/testFile.lua
vendored
Normal file
81
deps/src/lualogging/tests/testFile.lua
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
local GLOBAL_OS_DATE = os.date
|
||||
local GLOBAL_IO_OPEN = io.open
|
||||
|
||||
local buffer_mode do
|
||||
local dir_separator = _G.package.config:sub(1,1)
|
||||
local is_windows = dir_separator == '\\'
|
||||
if is_windows then
|
||||
-- Windows does not support "line" buffered mode, see
|
||||
-- https://github.com/lunarmodules/lualogging/pull/9
|
||||
buffer_mode = "no"
|
||||
else
|
||||
buffer_mode = "line"
|
||||
end
|
||||
end
|
||||
|
||||
local mock = {
|
||||
date = nil,
|
||||
handle = {}
|
||||
}
|
||||
|
||||
io.open = function (file, mode) --luacheck: ignore
|
||||
if (not string.find(file, "^__TEST*")) then
|
||||
return GLOBAL_IO_OPEN(file, mode)
|
||||
end
|
||||
|
||||
mock.handle[file] = {}
|
||||
mock.handle[file].lines = {}
|
||||
mock.handle[file].mode = mode
|
||||
return {
|
||||
setvbuf = function (_, s)
|
||||
mock.handle[file].setvbuf = s
|
||||
end,
|
||||
write = function (_, s)
|
||||
table.insert(mock.handle[file].lines, s)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
os.date = function (...) --luacheck: ignore
|
||||
return mock.date
|
||||
end
|
||||
|
||||
local log_file = require "logging.file"
|
||||
|
||||
mock.date = "2008-01-01"
|
||||
local logger = log_file("__TEST%s.log", "%Y-%m-%d")
|
||||
|
||||
assert(mock.handle["__TEST"..mock.date..".log"] == nil)
|
||||
|
||||
logger:info("logging.file test")
|
||||
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].mode == "a")
|
||||
assert(#mock.handle["__TEST"..mock.date..".log"].lines == 1)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].setvbuf == buffer_mode)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].lines[1] == "2008-01-01 INFO logging.file test\n")
|
||||
|
||||
mock.date = "2008-01-02"
|
||||
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].mode == "a")
|
||||
assert(#mock.handle["__TEST"..mock.date..".log"].lines == 2)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].setvbuf == buffer_mode)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].lines[1] == "2008-01-02 DEBUG debugging...\n")
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].lines[2] == "2008-01-02 ERROR error!\n")
|
||||
|
||||
mock.date = "2008-01-03"
|
||||
|
||||
logger:info({id = "1"})
|
||||
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].mode == "a")
|
||||
assert(#mock.handle["__TEST"..mock.date..".log"].lines == 1)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].setvbuf == buffer_mode)
|
||||
assert(mock.handle["__TEST"..mock.date..".log"].lines[1] == '2008-01-03 INFO {id = "1"}\n')
|
||||
|
||||
os.date = GLOBAL_OS_DATE --luacheck: ignore
|
||||
io.open = GLOBAL_IO_OPEN --luacheck: ignore
|
||||
|
||||
print("File Logging OK")
|
||||
|
||||
16
deps/src/lualogging/tests/testMail.lua
vendored
Normal file
16
deps/src/lualogging/tests/testMail.lua
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
local log_email = require"logging.email"
|
||||
|
||||
local logger = log_email {
|
||||
rcpt = "mail@host.com",
|
||||
from = "mail@host.com",
|
||||
{
|
||||
subject = "[%level] logging.email test",
|
||||
}, -- headers
|
||||
}
|
||||
|
||||
logger:info("logging.email test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
|
||||
print("Mail Logging OK")
|
||||
|
||||
30
deps/src/lualogging/tests/testRollingFile.lua
vendored
Normal file
30
deps/src/lualogging/tests/testRollingFile.lua
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
local log_file = require "logging.rolling_file"
|
||||
|
||||
local max_size = 1024 * 10 --10kb
|
||||
local max_index = 5
|
||||
local total_log_size = max_size * max_index --more than needed because of the log pattern
|
||||
local log_filename = "test.log"
|
||||
local logger = log_file(log_filename, max_size, max_index)
|
||||
|
||||
|
||||
-- it will generate the log + max_index backup files
|
||||
local size = 0
|
||||
while size < total_log_size do
|
||||
local data = string.format("Test actual size[%d]", size)
|
||||
logger:debug(data)
|
||||
size = size + #data
|
||||
end
|
||||
|
||||
-- lets test if all files where created
|
||||
for i = 1, max_index do
|
||||
local file = assert(io.open(log_filename.."."..i, "r"))
|
||||
-- since there is an exact precision on the rolling
|
||||
-- (it can be a little less or a little more than the max_size)
|
||||
-- lets just test if the file is empty.
|
||||
|
||||
assert(file:seek("end", 0) > 0)
|
||||
file:close()
|
||||
end
|
||||
|
||||
print("RollingFile Logging OK")
|
||||
|
||||
25
deps/src/lualogging/tests/testSQL.lua
vendored
Normal file
25
deps/src/lualogging/tests/testSQL.lua
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
local log_sql = require "logging.sql"
|
||||
local _, luasql = pcall(require, "luasql")
|
||||
local has_module = pcall(require, "luasql.sqlite3")
|
||||
if not has_module then
|
||||
print("SQLite 3 Logging SKIP (missing luasql.sqlite3)")
|
||||
else
|
||||
if not luasql or not luasql.sqlite3 then
|
||||
print("Missing LuaSQL SQLite 3 driver!")
|
||||
else
|
||||
local env = luasql.sqlite3()
|
||||
|
||||
local logger = log_sql{
|
||||
connectionfactory = function()
|
||||
return assert(env:connect("test.db"))
|
||||
end,
|
||||
keepalive = true,
|
||||
}
|
||||
|
||||
logger:info("logging.sql test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
print("SQLite 3 Logging OK")
|
||||
end
|
||||
end
|
||||
|
||||
10
deps/src/lualogging/tests/testSocket.lua
vendored
Normal file
10
deps/src/lualogging/tests/testSocket.lua
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
local log_sock = require"logging.socket"
|
||||
|
||||
local logger = log_sock("localhost", 5000)
|
||||
|
||||
logger:info("logging.socket test")
|
||||
logger:debug("debugging...")
|
||||
logger:error("error!")
|
||||
|
||||
print("Socket Logging OK")
|
||||
|
||||
Reference in New Issue
Block a user