Conversation
| try: | ||
| txt = str(txt).strip()[:length] | ||
| sz = int(sz) | ||
| if len(txt) > sz: txt = txt[:sz] + " ..." |
There was a problem hiding this comment.
Revisiting a recent change on managing log message lengths, having tested it with other packages (i.e. OSlg as a dependency).
OSlg shall no longer have a built-in limit to log message lengths. Good option to offer, but not one to bake in. All OSlg log functions (e.g. zero, mismatch) call on log, which itself calls trim:
- ensures valid log message strings
- trims final log message length if requested by user
- if trimming not requested by user, leaves log message as is
Each OSlg log function now has an additional sz parameter, which is None by default (and therefore ignored). Users are free to set sz to e.g. "160" chars.
| l4 = 2 # "[]" | ||
| self.assertEqual(l1 + l2 + l3 + l4, 231) | ||
| self.assertEqual(len(a), l1 + l2 + l3 + l4) | ||
| self.assertEqual(oslg.mismatch("x", "String", list, a, FTL, None, 156), None) |
There was a problem hiding this comment.
To request a shortened logged message, users need to activate the last log function parameter, sz (here, "156").
Tested, works, hopefully done. Certainly not keen on re-releasing in the future (unless absolutely necessary, e.g. bug, future Python change). So definitely trying to nail this down ASAP.
Running larger test suites (e.g. parent packages, calling upon OSlg). Will only merge and re-release OSlg once all other test suites pass.
In sync with a current Ruby OSlg revision in log message length management/approach.