diff options
Diffstat (limited to '_.lua')
-rwxr-xr-x | _.lua | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -16,14 +16,22 @@ local _ = {} | |||
16 | _.version = '0.0 crap' | 16 | _.version = '0.0 crap' |
17 | 17 | ||
18 | 18 | ||
19 | -- TODO - add the rest of the logging and debug level stuff from apt-panopticon. | 19 | _.verbosity = 2 |
20 | local log = function(v, t, s) | ||
21 | if v <= _.verbosity then | ||
22 | if 3 <= _.verbosity then t = os.date('!%F %T') .. " " .. t end | ||
23 | print(t .. ": " .. s) | ||
24 | end | ||
25 | io.flush() | ||
26 | end | ||
27 | |||
20 | -- This sets the global values, here and in the caller. | 28 | -- This sets the global values, here and in the caller. |
21 | D = function(s) print('DEBUG ' .. s); io.flush() end | 29 | D = function(s) log(4, 'DEBUG ', s) end |
22 | I = function(s) print('INFO ' .. s); io.flush() end | 30 | I = function(s) log(3, 'INFO ', s) end |
23 | T = function(s) print('TIMEOUT ' .. s); io.flush() end | 31 | T = function(s) log(2, 'TIMEOUT ', s) end |
24 | W = function(s) print('WARNING ' .. s); io.flush() end | 32 | W = function(s) log(1, 'WARNING ', s) end |
25 | E = function(s) print('ERROR ' .. s); io.flush() end | 33 | E = function(s) log(0, 'ERROR ', s) end |
26 | C = function(s) print('CRITICAL ' .. s); io.flush() end | 34 | C = function(s) log(-1, 'CRITICAL ', s) end |
27 | 35 | ||
28 | 36 | ||
29 | local optionsCommon = | 37 | local optionsCommon = |
@@ -41,6 +49,18 @@ local optionsCommon = | |||
41 | os.exit(0) | 49 | os.exit(0) |
42 | end | 50 | end |
43 | }, | 51 | }, |
52 | ['-q'] = {help = 'Decrease verbosity level.', | ||
53 | func = function(self, options, a, args, i) | ||
54 | if _.verbosity > -1 then _.verbosity = _.verbosity - 1 end | ||
55 | print('New verbosity level is ' .. _.verbosity) | ||
56 | end | ||
57 | }, | ||
58 | ['-v'] = {help = 'Increase verbosity level.', | ||
59 | func = function(self, options, a, args, i) | ||
60 | if _.verbosity < 4 then _.verbosity = _.verbosity + 1 end | ||
61 | print('New verbosity level is ' .. _.verbosity) | ||
62 | end | ||
63 | }, | ||
44 | } | 64 | } |
45 | optionsCommon['--help'] = optionsCommon['help'] | 65 | optionsCommon['--help'] = optionsCommon['help'] |
46 | 66 | ||