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

[cbuild] It is unclear what cbuild --log does (clarified) #1042

Closed
ReinhardKeil opened this issue Jun 30, 2023 · 6 comments
Closed

[cbuild] It is unclear what cbuild --log does (clarified) #1042

ReinhardKeil opened this issue Jun 30, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@ReinhardKeil
Copy link
Collaborator

I was using this command with csolution-examples but did not see any additional log file that is created.

>cbuild Hello.csolution.yml -q -c .Release --log ./out/AVH -r

Could someone explain?

@ReinhardKeil ReinhardKeil added the discussion Indicates an issue being in discussion label Jun 30, 2023
@brondani
Copy link
Collaborator

--log arg            Save output messages in a log file

You should give the full name for the log file not only the directory, for example:

cbuild Hello.csolution.yml -c .Release --log myLog.txt

@jkrech
Copy link
Member

jkrech commented Jun 30, 2023

It is perfectly valid to specify a log filename without extension, however in the above example AVH is the name of the directory where the build artifacts will be stored in out/AVH/.

It seems that if you specify a directory that does not exist (./log) as part of the log file cbuild gives this error:
open ./log/AVH: The system cannot find the path specified.

@jkrech jkrech added enhancement New feature or request and removed discussion Indicates an issue being in discussion labels Jul 4, 2023
@jkrech jkrech changed the title It is unclear what cbuild --log does [cbuild] It is unclear what cbuild --log does (clarified) Jul 4, 2023
@soumeh01
Copy link
Collaborator

soumeh01 commented Aug 2, 2023

--log option takes the name of the file (with/without extn), provided that the parent path should be existing. If the path doesn't exist or is a path of a directory. cbuild throws a warning and continue the execution.

$ cbuild .Hello.csolution.yml -r --log unknown/test.log
warning cbuild: error creating log file
open unknown/test.log: The system cannot find the path specified.
...

or

$ cbuild ./Hello.csolution.yml -r --log ./out/AVH
warning cbuild: error creating log file
open ./out/AVH: is a directory
...

In my opinion, The behavior should be in line with the redirect > operator. Which redirects all this output to a file and throws an ERROR when the path doesn't exist

$ cbuild ./Hello.csolution.yml -r > unknown/test_redirect.log
bash: unknown/test_redirect.log: No such file or directory

or

$ cbuild ./csolution-examples/Hello/Hello.csolution.yml -r > ./out/AVH
bash: ./out/AVH: Is a directory

Proposal

I would propose to have a behavior the same as the > operator. which is

  • Parent path to the logfile should be existing
  • Throw error instead of warning. When the path doesn't exist or the path specified is the path to a directory.
  • Stop the execution when cbuild is unable to create a logfile

@soumeh01
Copy link
Collaborator

soumeh01 commented Aug 9, 2023

@ReinhardKeil @jkrech
Do you have any comments/feedback/suggestions on the above proposal?

@jkrech
Copy link
Member

jkrech commented Aug 10, 2023

a) throwing an error and stopping the execution is the right approach in case the log file cannot be written (e.g. also due to lack of access permission)
b) why do we implement --log if it does exactly the same as redirecting the output using the > operator in the first place?
The benefit I was expecting for this dedicated option is that the user does not need to ensure that the directory exists, just like with the --output option. I think this would simplify the scripting and avoid the user stumbling.

@soumeh01
Copy link
Collaborator

In reference to the point b mentioned, The difference when having --log and > operator is,

cbuild ./Hello.csolution.yml -r > test_redirect.log only captures in the log file (NO logs on STDOUT). If user wants to see the logs on stdout and capture them in the file as well. He/she will have to use different extended command based on the operating system (tee or type or 'Tee-Object') for e.g.

  • In UNIX based bash : cbuild ./Hello.csolution.yml -r 2>&1 | tee test_redirect.log
  • In Windows cmd or powershell : cbuild ./Hello.csolution.yml -r > test_redirect.log 2>&1 & type test_redirect.log

but with --log options, The command is always the same irrespective of the operating system
cbuild ./Hello.csolution.yml -r --log test.log

jkrech pushed a commit to Open-CMSIS-Pack/cbuild that referenced this issue Aug 11, 2023
Addressing: Open-CMSIS-Pack/devtools#1042

- If the path doesn't exist, create a log file path
- Throws an error, when unable to create a directory or file
- Stop the execution in case of an error
@jkrech jkrech closed this as completed Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants