Skip to content

Add Logging & Debugging Support #6

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

Open
Aha43 opened this issue Mar 3, 2025 · 0 comments
Open

Add Logging & Debugging Support #6

Aha43 opened this issue Mar 3, 2025 · 0 comments

Comments

@Aha43
Copy link
Owner

Aha43 commented Mar 3, 2025

For debugging purposes, it would be useful to:

  • Log when a handler is discovered.
  • Log when a command matches or fails to match.

🔹 Improvement Suggestion: Add a ILogger (from Microsoft.Extensions.Logging) and allow users to enable logging.

Modify Spf constructor:

private readonly ILogger<Spf> _logger;

public Spf(string[] args, IServiceCollection services, string baseNamespace = "", ILogger<Spf>? logger = null)
{
    _logger = logger ?? NullLogger<Spf>.Instance;
    _baseNamespace = baseNamespace.ToLower();
    var serviceProvider = services.BuildServiceProvider();
    _serviceProvider = serviceProvider;
    _handlers = DiscoverHandlers(serviceProvider);
    _exitor = serviceProvider.GetService<ISpfExitor>();
    _noMatchHandler = serviceProvider.GetService<ISpfNoPromptMatchHandler>();
}
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

No branches or pull requests

1 participant