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

Log to the output/log window #3095

Open
MIchaelMainer opened this issue Aug 8, 2023 · 5 comments
Open

Log to the output/log window #3095

MIchaelMainer opened this issue Aug 8, 2023 · 5 comments
Labels
enhancement New feature or request help wanted Issue caused by core project dependency modules or library IntelliJ Plugin Work for IntelliJ platform plugin
Milestone

Comments

@MIchaelMainer
Copy link
Member

Generate output returns the log information so you can display that into the log window. Include model classes for logging the response results.

@MIchaelMainer MIchaelMainer added the IntelliJ Plugin Work for IntelliJ platform plugin label Aug 8, 2023
@baywet baywet added the enhancement New feature or request label Aug 9, 2023
@baywet baywet added this to Kiota Aug 9, 2023
@baywet baywet moved this to Todo in Kiota Aug 9, 2023
@baywet baywet added this to the Backlog milestone Aug 9, 2023
@baywet
Copy link
Member

baywet commented Aug 9, 2023

@MIchaelMainer Thanks for creating the issue and the label. Don't hesitate to create additional issues if it help you or @Hossain2024 keep tracks of things and prioritizing work.

@MIchaelMainer
Copy link
Member Author

@Hossain2024 When we add new backlog items, let's:

  1. Add them to the Kiota project,
  2. Set the Status to Todo,
  3. Set the Backlog milestone

These can be set in the right column of the issue interface.
image

@baywet baywet added the help wanted Issue caused by core project dependency modules or library label Sep 5, 2023
@gpltaylor
Copy link

I understand the complexities of building large scale developed software and I thank you and the community for your efforts.

When using this for the demos everything is perfect. However, when trying to use this against a real commercial API I am having issues.

I am unable to see any requests or response Data. I can't see why errors are being returned from the API and the logs are empty.

I am also unable to inject an ILogger into the Generated code, so I am going to give up using the CLI Generator and jump onto the standard C# generator. If that fails, it back to bear backing this beast.

The API am hitting is under development and is changing/erroring multiple times per day. This tool is great if the API is sold. But in real life this is not the case; or at least not in my world.

I am doing the following:

SHELL := /bin/bash

build:
	dotnet build --no-cache

send-full-quote: build
	dotnet run -- full-quote post --client-id=fluentmoney --client-secret=bob --body="$$(cat sample-request.json)"

I get

Unhandled exception: KiotaPostsCLI.Client.Models.ErrorResponse: Exception of type 'KiotaPostsCLI.Client.Models.ErrorResponse' wa
   at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponse(HttpResponseMessage response, DictiotyForAttributes, CancellationToken cancellationToken)

So this tells me nothing...
Adding the following monstrosity to the RequestBuilder

                try { 
                    var response = await reqAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping: errorMapping, cancellationToken: cancellationToken) ?? Stream.Null;
                    response = (response != Stream.Null) ? await outputFilter.FilterOutputAsync(response, query, cancellationToken) : response;
                    var formatter = outputFormatterFactory.GetFormatter(output);
                    await formatter.WriteOutputAsync(response, cancellationToken);

                } catch (Exception ex) {
                    throw new Exception($"Error getting response {ex.InnerException.Source}");
                    // Loop over all exceptions and store the messaghe and scourse into a string
                    var inner = ex.InnerException;
                    var message = string.Empty;
                    var source = string.Empty;
                    while (inner != null) {
                        message += inner.Message;
                        source += inner.Source;
                        inner = inner.InnerException;
                    }
                    throw new Exception($"Error getting response {message} {source}");

At least I got this...

dotnet run -- full-quote post --client-id=fluentmoney --client-secret=bob --body="$(cat sample-request.json)"
Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at KiotaPostsCLI.Client.FullQuote.FullQuoteRequestBuilder.<>c__DisplayClass1_0.<<BuildPostCommand>b__1>d.MoveNext() in C:\dev\fluent.prototypes\Kiota\<removed>\src\Client\FullQuote\FullQuoteRequestBuilder.cs:line 87
--- End of stack trace from previous location ---

Allowing Logging and being able log the Request and Response would be amazing! Or at least to the console using an injected ILogger.

@KennethHoff
Copy link

@gpltaylor I only just now noticed that you wrote this - less than half an hour before I made this issue.

Your feedback here would be nice :)

@baywet
Copy link
Member

baywet commented Nov 20, 2023

Hi everyone,
Thanks for reaching out.
This issue was originally dedicated to adding kiota generation log to the output window in the JetBrains integration we have started over the summer.
Since another issue has been created on the other topic (see previous reply from @KennethHoff), let's all head over that issue and focus the discussions there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Issue caused by core project dependency modules or library IntelliJ Plugin Work for IntelliJ platform plugin
Projects
Status: New📃
Development

No branches or pull requests

5 participants