File: testSQL.lua

package info (click to toggle)
lua-logging 1.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 512 kB
  • sloc: makefile: 16; sh: 3
file content (25 lines) | stat: -rw-r--r-- 641 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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