aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x_.lua34
1 files changed, 27 insertions, 7 deletions
diff --git a/_.lua b/_.lua
index 945f4f2..43f3f59 100755
--- a/_.lua
+++ b/_.lua
@@ -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
20local 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()
26end
27
20-- This sets the global values, here and in the caller. 28-- This sets the global values, here and in the caller.
21D = function(s) print('DEBUG ' .. s); io.flush() end 29D = function(s) log(4, 'DEBUG ', s) end
22I = function(s) print('INFO ' .. s); io.flush() end 30I = function(s) log(3, 'INFO ', s) end
23T = function(s) print('TIMEOUT ' .. s); io.flush() end 31T = function(s) log(2, 'TIMEOUT ', s) end
24W = function(s) print('WARNING ' .. s); io.flush() end 32W = function(s) log(1, 'WARNING ', s) end
25E = function(s) print('ERROR ' .. s); io.flush() end 33E = function(s) log(0, 'ERROR ', s) end
26C = function(s) print('CRITICAL ' .. s); io.flush() end 34C = function(s) log(-1, 'CRITICAL ', s) end
27 35
28 36
29local optionsCommon = 37local 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}
45optionsCommon['--help'] = optionsCommon['help'] 65optionsCommon['--help'] = optionsCommon['help']
46 66