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

[ZCO-230] Provide different output styles #3

Closed
czottmann opened this issue May 18, 2023 · 15 comments
Closed

[ZCO-230] Provide different output styles #3

czottmann opened this issue May 18, 2023 · 15 comments
Labels
enhancement New feature or request linear Created by Linear-GitHub Sync

Comments

@czottmann
Copy link
Owner

czottmann commented May 18, 2023

Right now, there's only the table style but it might be worthwhile to also provide a more traditional console log output style and/or CSV etc.

Should be configurable via a Settings view.

ZCO-230

@czottmann czottmann added the enhancement New feature or request label May 18, 2023
@czottmann czottmann added the linear Created by Linear-GitHub Sync label Oct 13, 2023
@czottmann czottmann changed the title Provide different output styles [ZCO-230] Provide different output styles Oct 13, 2023
@fyears
Copy link
Contributor

fyears commented Feb 25, 2024

Hi thanks for your plugin and it really saves my time.

And I am also +1 for different output styles. Especially my log outputs json with have lots of line breaks, which will break the table styles easy.

I think the most obvious way is just wrapping each result of each call of console.log using ```. Something like this is sufficient:

```
time: 2024-02-25T11:00:14.773Z
plugin:abc:114931:15
level: log
output: xxxxxxxxxx
```

```
time: 2024-02-25T11:00:14.773Z
plugin:abc:114931:15
level: log
output:  a json is here: {
  "aaa":"bbb",
  "ccc":"ddd"
}
```

@czottmann
Copy link
Owner Author

czottmann commented Feb 26, 2024

@fyears Thanks for the suggestion. Quick question, how do you work with the log output? Do you get files from your users, or do you use it locally on your own log output?

I'm asking because I believe there are two ways to deal with the output:

  1. You read it, i.e. "human consumption"
  2. You feed it to a script, i.e. parsing by machine.

Logstravaganza was initially written for (1) but I've realized that having it output NDJSON (as an option) would be beneficial for (2).

@fyears
Copy link
Contributor

fyears commented Mar 3, 2024

Hi! I debug my plugin on ios and find your plugin very useful.

However, in my plugin I use lots of console.log(JSON.stringify(obj,null,2) so they will break the table generated by your plugin.

@czottmann
Copy link
Owner Author

Got it, thank you!

I've played around with NDJSON (newline delimited JSON) which is great for streaming structured data to the terminal. Every line is a JSON object, so keeping an eye on new log entries from the terminal is easy:

tail -f output.ndjson | jq

That said, I've decided to add NDJSON logging for sure but I might add other formats, too!

@fyears
Copy link
Contributor

fyears commented Mar 15, 2024

so are you going to output ndjson files? i am concerned that whether it's directly readbale in obsidian...

@czottmann
Copy link
Owner Author

Yes, I'll add them. My internal timeline got screwed over hard due to some emergencies related to my for-purchase apps. Since those are what keeps me afloat, they'll always have highest priority. 😉

i am concerned that whether it's directly readbale in obsidian..

They are. The user has to enable SettingsFiles and linksDetect all file extensions to see them in the file explorer, however.

@fyears
Copy link
Contributor

fyears commented Mar 18, 2024

But are they readable in obsidian? or, say, need vscode to read?

I mean, the plugin is very useful on iOS where there is no console. I believe the generated note being directly readable (i.e. in markdown format) in Obsidian is greatly useful.

@fyears
Copy link
Contributor

fyears commented Mar 18, 2024

And would you like to accept pull requests? I could contribute to the project by adding even more output formats if you’d like.

@czottmann
Copy link
Owner Author

No, it wouldn't be readable in Obsidian; I believe Obsidian simply hands it over to the OS, saying "deal with it, it's not one of mine". Here's a test file, simply drop it in your vault to test it out:

LOGGING-NOTE (Chonky-Boi).json

For this file, the extension would be .ndjson but GitHub doesn't know that extension and won't upload those files.

And would you like to accept pull requests? I could contribute to the project by adding even more output formats if you’d like.

Yes! But please let me implement the general settings & output format handling first. I have a rather clear idea of what it's going to look like, and have it sketched out already, but there's no code to show yet. Give me a few days, please. It's on my plate for this week!

@fyears
Copy link
Contributor

fyears commented Mar 18, 2024

OK!! I am looking forward to it! Thank you so much!

@czottmann
Copy link
Owner Author

Work has begun. I'll keep you posted, @fyears :)

@czottmann
Copy link
Owner Author

czottmann commented Mar 22, 2024

The release/2.0.x branch is my WIP. I've rewritten the whole plugin, basically. There's a new settings tab and a rather simple formatters system – basically, for each output format there's a little object, containing metadata and a formatting function. That function is called for every intercepted console message, and returns the new line to be written to the output file. Take a look.

I'll release that version before Tuesday, and then I'll be open to PR's ;)

@fyears
Copy link
Contributor

fyears commented Mar 23, 2024

Sure!

@czottmann
Copy link
Owner Author

Implemented, will be rolled out in the upcoming v2.0.0.

@czottmann
Copy link
Owner Author

@fyears The big update is out – let me know if you have questions regarding the formatters or anything. Feel free to hit me up on the Plugin Forum ("Log in with GitHub" is enabled!), or on Mastodon or Bluesky.

@fyears fyears mentioned this issue Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

2 participants