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

Logger pretty newlines #320

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

RiskoZoSlovenska
Copy link
Contributor

This pull request adds a new boolean client option prettyNewlines (true by default) and a new Logger option + mutators which, when true, makes the logger pad newlines so that they align with the timestamp label. This is just a cosmetic change to make logging multi-line strings neater.

As an example, what before was:

2021-10-23 15:31:25 | [INFO]     | Hi!
This is a
multiline string!

now becomes:

2021-10-23 15:31:25 | [INFO]     | Hi!
                                 | This is a
                                 | multiline string!

line[5] = gsub(
line[5],
'\r?\n',
'%0' .. rep(' ', #line[1] + 16 - 2) .. '| ' -- Timestamp + label (10) + separators (6)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show where you get 16 from? We probably shouldn't hardcode this if it can be dynamically generated (maybe as a module local value).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label (line[3]) is always length 10. The two separators (|) (line[2] and line[4]) are both 3, so 6 total.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't hardcode this if it can be dynamically generated (maybe as a module local value).

Can you make this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?
75018a4

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.

2 participants