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

support \r\n lines sep #16

Closed

Conversation

vitalyshatskikh
Copy link
Contributor

@vitalyshatskikh vitalyshatskikh commented Jun 15, 2024

I've moved reader updates from #15 into separate PR

@michurin
Copy link
Owner

Could you explain, please, what problem are you solving? \r does not affect json parsing.

@vitalyshatskikh
Copy link
Contributor Author

It is still about windows :-)

You're right, JSONs are fine. But records that are not valid json has '\r' at the end.

For instance, one of the behavioral tests: fake-server.sh prints three records. If we try to do the same using win cmd:

>powershell .\srv.ps1 | go run .\cmd\...
2024-12-02T12:00:00-05:00 [INFO] OK source.file=/Users/slog/main.go source.function=main.main source.line=14 user=1
INVALID JSON: "Broken raw error message\r"
2024-12-02T12:05:00-05:00 [INFO] OK source.file=/Users/slog/main.go source.function=main.main source.line=14 user=2

Look at the end of 'INVALID JSON...' record.

After this PR pplog will print:

>powershell .\srv.ps1 | go run .\cmd\...
2024-12-02T12:00:00-05:00 [INFO] OK source.file=/Users/slog/main.go source.function=main.main source.line=14 user=1
INVALID JSON: "Broken raw error message"
2024-12-02T12:05:00-05:00 [INFO] OK source.file=/Users/slog/main.go source.function=main.main source.line=14 user=2

@michurin
Copy link
Owner

Hmmm... It's understandable... However, as linux user I prefer to see such strange characters...

What do you think about to delegate it to templating?

Haw about create template function and let everyone use it or not by their own choice? Like that

PPLOG_ERRLINE='INVALID: {{ .TEXT | trimSpaces | printf "%q" }}' go run ./cmd/pplog/... echo -e 'asdf\r'
INVALID: "asdf"

It's templating! unlimited possibilities for everyone :-) (it wont work yet, this function does not exist)

@michurin
Copy link
Owner

How about this way? #17

@michurin
Copy link
Owner

The more I look at my PR (#17), the more I like it :-) I'll merge it and I would recommend to use templates to solve such problems.

@michurin michurin closed this Jun 16, 2024
@vitalyshatskikh
Copy link
Contributor Author

The more I look at my PR (#17), the more I like it :-) I'll merge it and I would recommend to use templates to solve such problems.

Great job!

@vitalyshatskikh vitalyshatskikh deleted the support_rn_lines_sep branch June 18, 2024 06:37
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