-
Notifications
You must be signed in to change notification settings - Fork 0
Revists log message length approach #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ def test01_oslg_initialized(self): | |
| self.assertEqual(oslg.msg(FTL), "Failure, triggered fatal errors") | ||
| self.assertNotEqual(oslg.msg(FTL), "Debugging ...") | ||
| self.assertEqual(oslg.trim(" oslg "), "oslg") | ||
| self.assertEqual(oslg.trim(" oslg ", 3), "osl") | ||
| self.assertEqual(oslg.trim(" oslg ", 3), "osl ...") | ||
| self.assertEqual(oslg.trim(" oslg ", 64), "oslg") | ||
| self.assertEqual(oslg.reset(INF), INF) | ||
| self.assertEqual(oslg.clean(), INF) | ||
|
|
@@ -99,6 +99,30 @@ def test03_oslg_invalid_argument_log(self): | |
| self.assertEqual(oslg.clean(), INF) | ||
| self.assertEqual(oslg.level(), INF) | ||
|
|
||
| # Longish error message, exceeding 160 chars. | ||
| a = str([i+1 for i in range(60)]) | ||
| l1 = 3 * 9 # "1, " + "2, " + "3, " ...+ "9, " | ||
| l2 = 4 * (59 - 9) # "10, " + "11, " + 12, ...+ "59, " | ||
| l3 = 2 # "60" | ||
| 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) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To request a shortened logged message, users need to activate the last log function parameter, 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. |
||
| self.assertEqual(oslg.status(), FTL) | ||
| str1 = "'x' str? expecting list " # 24 chars | ||
| str2 = "([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " # 45 chars | ||
| str3 = "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, " # 44 chars | ||
| str4 = "25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, ..." # 47 chars | ||
| str0 = str1 + str2 + str3 + str4 | ||
| self.assertEqual(len(str0), 160) # 156 + " ..." | ||
| self.assertEqual(len(oslg.logs()[0]["message"]), len(str0)) | ||
| self.assertEqual(oslg.logs()[0]["message"], str0) | ||
| self.assertEqual(oslg.level(), INF) | ||
| self.assertEqual(len(oslg.logs()), 1) | ||
| self.assertEqual(oslg.reset(INF), INF) | ||
| self.assertEqual(oslg.clean(), INF) | ||
| self.assertEqual(oslg.level(), INF) | ||
|
|
||
| def test04_oslg_mismatched_argument_log(self): | ||
| m1 = "'radius' str? expecting float (area)" | ||
| m2 = "'roster' list? expecting dict (index)" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 onlog, which itself callstrim:Each OSlg log function now has an additional
szparameter, which is None by default (and therefore ignored). Users are free to setszto e.g. "160" chars.