[Nut-upsdev] logging strategy
Greg Troxel
gdt at lexort.com
Sun Jan 15 16:12:39 GMT 2023
I am looking at bestfortress and trying to figure out and fix some
things, which is causing me to try to improve logging first. A few
questions:
0) The developer guide doesn't seem to address any of this, or did I
miss it?
1) It seems upsdebugx prints to stdout instead of syslog if in
foreground. That's great but I didn't figure it out from docs.
2) I didn't find a plan for debug levels, so I made one up for
bestfortress and put it in comments. Did I miss a plan? Should there
be on in common.h? someplace else? Probably it's ok for each driver
to have its own plan.
3) It looks like upsdebugx either prints (if foreground) or syslog, and
if syslog one gets the program name. So upsdebugx should therefore 1)
not have the driver name and 2) should have a function, for things that
aren't clearly locatable. Correct?
4) I want to print mostly-ASCII strings with non-ASCII escaped. Is
there a routine to convert strings? s_upsdebug_ascii output is
difficult for mostly-ascii. There is a log of a read string "\nOK" that
is messy (and there's a real bug lurking that this exposes).
I think I want (actually I want octal because I was raised PDP-11, but
not trying to rock that boat):
ABCD\{LF}EFG\[89]\\
or similar for printf("ABCD\nEFG%c\\", 0x89). The point is to be
- compact for mostly ascii
- unambigous
- guaranteed printable only
- otherwise as simple as possible
How would people feel about adjusting upsdebug_ascii to do this? I
would consider a PR if it is ok, and skip the effort if not.
More information about the Nut-upsdev
mailing list