diff options
| author | dvs1 | 2024-10-25 17:24:10 +1000 | 
|---|---|---|
| committer | dvs1 | 2024-10-25 17:24:10 +1000 | 
| commit | 9c55542f019ccaf40db9c5f3270d8ff5945bb8cc (patch) | |
| tree | 1e6eff69d4eacf8a09be5e21be86a0fcdf674ead /_.lua | |
| parent | Seems to be he only way to assign copies of table elemnts to that table at co... (diff) | |
| download | JackOnAllDevices-9c55542f019ccaf40db9c5f3270d8ff5945bb8cc.zip JackOnAllDevices-9c55542f019ccaf40db9c5f3270d8ff5945bb8cc.tar.gz JackOnAllDevices-9c55542f019ccaf40db9c5f3270d8ff5945bb8cc.tar.bz2 JackOnAllDevices-9c55542f019ccaf40db9c5f3270d8ff5945bb8cc.tar.xz | |
Added the rest of the logging and debug level stuff from apt-panopticon, except for file logging
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 | ||
