lua-simplelog  Check-in [97d92be459]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a way to test and see an example.

test.lua provides an example for logging, and currently tests functionality so one can see that it works accordingly, however, manually.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:97d92be459e0d9349d81981c8ac8de0b245407cde252bc57959647a3fa5a61a8
User & Date: llmII 2019-07-11 15:22:16
Context
2019-07-11
17:46
Fix README to match test.lua check-in: 0bc6556ee0 user: llmII tags: trunk
15:22
Add a way to test and see an example. check-in: 97d92be459 user: llmII tags: trunk
14:46
More slight changes to documentation. check-in: 5c0eaaa2d0 user: llmII tags: trunk
Changes

Added test.lua.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local log_config = {
  -- this directory must exist!
  -- must end with /
  dir = '/tmp/simplelog/',
  daemonized = false,
  debug_info = true,
  logs = {
    default = {
      levels = {
        write = 'info',
        print = 'info'
      }
    },
    log1 = {
      levels = {
        write = 'info',
        print = 'trace'
      }
    }
  }
}

print 'make sure you created /tmp/simplelog and have permissions to use it'

local log_manager = require 'simplelog' (log_config)
local uses_default = log_manager:open 'loga'
local log1 = log_manager:open 'log1'
-- should not print or write to file
uses_default:trace 'This is a message'
-- should print and write to file
uses_default:error('Error %s', 1000)
-- should print but not write to file
log1:trace 'This is a message'
-- should print and write to file
log1:error 'This is a message too'
log_manager:closeall()

print 'Check that the following were printed:'
print '  "Error 1000" and "loga" on the same line'
print '  "This is a message" and "log1" on the same line'
print '  "This is a message too" and "log1" on the same line'

print 'Check for the following in /tmp/simplelog'
print '  /tmp/simplelog/loga.log'
print '  /tmp/simplelog/log1.log'
print '\n'

print 'Check for the lines in loga.log to look like the following:'
print '  "This is a message" does not exist'
print '  "Error 1000" should exist'

print 'Check for lines in log1.log to look like the following:'
print '  "This is a message too" should exist'