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 passing a swift-log Logger instance #150

Open
pepicrft opened this issue Dec 23, 2024 · 4 comments
Open

Support passing a swift-log Logger instance #150

pepicrft opened this issue Dec 23, 2024 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@pepicrft
Copy link
Contributor

We need to start differentiating between "logging" for which we'll use swift-log's interface, and "UI", which in the context of a CLI is the text that's part of the product experience and that's oriented towards communicating progress/actions to the developer that ran a command.

Noora components fall in the "UI" group, but I think it'd be beneficial to also log what the components do so that the logs can be used later on for debugging purposes.

@pepicrft pepicrft added enhancement New feature or request good first issue Good for newcomers labels Dec 23, 2024
@VaishaliDesai
Copy link
Contributor

Hello, I would like to take this up. New to the repository so might need some guidance here :)

@pepicrft
Copy link
Contributor Author

Hi @VaishaliDesai 👋🏼
Sure, that'd be amazing. The plan here is to support passing an instance of Logger, to each function in the Noorable protocol. For example:

func singleChoicePrompt<T: CaseIterable & CustomStringConvertible & Equatable>(
        title: TerminalText?,
        question: TerminalText,
        description: TerminalText?,
        collapseOnSelection: Bool
        logger: Logger
    ) -> T

And then use it in implementing each component to leave a trace of what happened. For example, in the above case it can be:

logger.info("Prompted the user to select an option for the question '\(question)'")
...
logger.info("Option '\(option)' selected for the question '\(question)'")

That way, consumers of this package can pass a Logger instance and provide a nice debugging experience to their users.

Let me know if you have any questions ;)

@VaishaliDesai
Copy link
Contributor

Amazing, makes sense, thanks a lot. I’ll work on it :)

@fortmarek
Copy link
Member

nit: I'd consider for the logger not to be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants