Skip to content
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

Alpha fixes: Fix issues from alpha1/2 releases #63

Merged
merged 12 commits into from
Oct 28, 2023
Merged

Conversation

hkupty
Copy link
Owner

@hkupty hkupty commented Oct 28, 2023

This PR contains a few improvements to penna mostly on formatting and internal logic
as they were observed by running 0.7-alpha1 and 0.7-alpha2 versions.

Additionally, this PR includes a few improvements to penna-dev for better
logging level granularity control.

This was not increasing the arguments array, possibly causing IOE
This commit contains a few use-cases in the test:

- A message can have fewer arguments than placeholders;
- A message can have the same number of arguments and placeholders;
- A message can have more arguments than placeholders;

Although cases 1 and 3 are inherently "wrong" (data won't be logged/data
will be missing), they shouldn't cause the logger to break.
There are many layers in this commit:

1. The new logic is arguably "clearer" and "easier to understand";
2. The new logic is more correct; and
3. The new logic is more performant.

1. Cleaner:

We already know when we put an escape in the string.
A double-escape invalidates a single-escape in terms of replacing the
placeholder, so moving the check to when we put the escape makes more
sense then.

2. More correct:
There are a few bugs in the previous logic:
- Arguments can be over and we still have placeholders;
- `buffer.put(buffer.position() - offset, DELIM_START);` causes chars to
  go missing;
- `null` arguments should be ignored and the placeholders untouched;
- escaped placeholders should not leave `\` behind.

3. More performant:
Virtually no difference in the benchmark, but logically it makes some
sense:
- We have more placeholders than usually we have escapes, so we don't
  need to constantly check the string for escapes.
- We do fewer checks (not necessarily a reason for being faster, but
  still);
There's no need to proxy configs. Much better alternatives will come
We should allow for per-test/block granularity. DEBUG/TRACE can be too
verbose for tests, unnecessarily.
This should allow for tests to change their log level in runtime
@hkupty hkupty merged commit 30015e3 into dev/0.7 Oct 28, 2023
1 check passed
@hkupty hkupty deleted the 0.7-alpha-fixes branch October 28, 2023 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant