Skip to content

#1544 Changed the daemon output from json to text #1570

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

Merged
merged 1 commit into from
Oct 24, 2022
Merged

#1544 Changed the daemon output from json to text #1570

merged 1 commit into from
Oct 24, 2022

Conversation

kittaakos
Copy link
Contributor

Motivation

To avoid encoding text to JSON on the CLI side.

Change description

Dropped the --log-format json options from the daemon spawn args.

Other information

Closes #1544

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@kittaakos kittaakos added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: CLI Related to Arduino CLI labels Oct 20, 2022
@nmzaheer
Copy link
Contributor

Should the code in the test file needs to be modified? It still allows json as logFormat.

protected override async getSpawnArgs(): Promise<string[]> {
const cliConfigPath = await this.initCliConfig();
return [
'daemon',
'--format',
'jsonmini',
'--port',
'0',
'--config-file',
cliConfigPath,
'-v',
'--log-format',
this.logFormat,
];
}

Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

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

Looking good!

The output is also more readable IMO
from:

daemon INFO {"level":"info","msg":"Required tool","time":"2022-10-21T10:31:19+02:00","tool":{"ToolName":"arduinoOTA","ToolVersion":"1.2.1","ToolPackager":"arduino"}}
{"level":"info","msg":"Required tool","time":"2022-10-21T10:31:19+02:00","tool":{"ToolName":"arm-none-eabi-gcc","ToolVersion":"7-2017q4","ToolPackager":"arduino"}}
{"level":"info","msg":"Required tool","time":"2022-10-21T10:31:19+02:00","tool":{"ToolName":"bossac","ToolVersion":"1.7.0-arduino3","ToolPackager":"arduino"}}
{"level":"info","msg":"Required tool","time":"2022-10-21T10:31:19+02:00","tool":{"ToolName":"openocd","ToolVersion":"0.10.0-arduino7","ToolPackager":"arduino"}}

to:

daemon INFO INFO[0009] Searching tools required for board arduino:samd:mkrwifi1010 
INFO[0009] Required tool                                 tool="arduino:[email protected]"
INFO[0009] Required tool                                 tool="arduino:[email protected]"
INFO[0009] Required tool                                 tool="arduino:[email protected]"
INFO[0009] Required tool                                 tool="arduino:arm-none-eabi-gcc@7-2017q4"
INFO[0009] Required tool                                 tool="arduino:[email protected]"
INFO[0009] Required tool                                 tool="arduino:[email protected]"

About the comment from nmzaheer: yes we should probably remove that flag from the test file too – nice catch, thank you for taking the time to look into the code!
Tests aren't failing anyway, so I won't request changes (in case @kittaakos you left that flag there on purpose for some reason)

@kittaakos
Copy link
Contributor Author

Do you want me to remove test?

@AlbyIanna
Copy link
Contributor

Do you want me to remove test?

Not really. For me it's the same, it doesn't really change anything I guess.

@kittaakos
Copy link
Contributor Author

OK. I will create a follow-up to clean up the text|json tests. There are multiple remarks:

  • initially, the CLI did not print out the daemon port, so it had to work with both json and text. That's why we had tests.
  • currently, it does not matter whether text or json is given after the --log-format because the address format is dictated by the daemon --format jsonmini|text|json flags.

@kittaakos
Copy link
Contributor Author

Follow-up: #1576

I am proceeding with the merge.

@kittaakos kittaakos merged commit 44751c3 into main Oct 24, 2022
@kittaakos kittaakos deleted the #1544 branch October 24, 2022 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to Arduino CLI topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Start the CLI daemon without the --log-format json
3 participants