Skip to content

Conversation

@Allan-N
Copy link
Contributor

@Allan-N Allan-N commented Sep 11, 2025

  • Allow one to control the debug levels before creating a session
  • Update what logs are generated based on the debug level (start off quiet with more info as the debug level is increased)

Copy link
Owner

@InterLinked1 InterLinked1 left a comment

Choose a reason for hiding this comment

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

I'm not sure I understand why the library itself (libcami) needs to be altered to do this. Isn't the debug logic you want to modify within amicli.c? (This is not part of libcami, it's a standalone program).

I think I'd prefer just a global variable in amicli.c unless there's a good reason to update the library for this.

@Allan-N
Copy link
Contributor Author

Allan-N commented Sep 11, 2025

The cami library provides the ami_set_debug_level() API. I added the matching ami_debug_level() API to retrieve the previously set value. As far as amicli, one could use a global but some folks avoid going down that path, especially for more involved projects with multiple source files. I just opted to use the new ami_debug_level() API to retrieve the current value.

@InterLinked1
Copy link
Owner

The cami library provides the ami_set_debug_level() API. I added the matching ami_debug_level() API to retrieve the previously set value.

That's to set the debug library of libcami, not of the program using libcami.

As far as amicli, one could use a global but some folks avoid going down that path, especially for more involved projects with multiple source files. I just opted to use the new ami_debug_level() API to retrieve the current value.

I think you're conflating two different things here - amicli.c is a separate thing that is not part of the CAMI library, just like simpleami.c. They are both just example programs that are in the tree for convenience. I don't think tying the library debug level to the program debug level is necessarily appropriate. I'd be okay with this change since it doesn't really do any harm, but I don't think it's the way that I intended consumers to interface with the library.

Only request is please update the commit message to amicli.c: Guard debug events based on libcami debug level or something like that to make it clear this is mainly a change to amicli.c and not the library.

- Allow one to control the debug levels before creating a session
- Update what logs are generated based on the debug level (start off quiet
  with more info as the debug level is increased)
@Allan-N Allan-N changed the title Improved debugging amicli.c: Guard debug events based on debug level Sep 11, 2025
@Allan-N
Copy link
Contributor Author

Allan-N commented Sep 11, 2025

I think you're conflating two different things here - amicli.c is a separate thing that is not part of the CAMI library, just like simpleami.c. ... I don't think tying the library debug level to the program debug level is necessarily appropriate.

Fair enough. I changed amicli.c to use a global ... but I'm still using the same -d argument to set the debug level both for the command and the CAMI library.

Only request is please update the commit message ...

Updated

@InterLinked1 InterLinked1 merged commit 3662256 into InterLinked1:master Sep 11, 2025
2 of 3 checks passed
@Allan-N Allan-N deleted the debug-levels branch September 11, 2025 19:50
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