NoaDebugger v1.2.0NoaDebugger v1.2.0
  • v1.6.0
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.0
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • v1.6.0
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.0
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • APILog

APILog

Displays the communication log of the Web API.

To display the communication log, it is necessary to output the log within the application that has incorporated the NOA Debugger. For how to output the communication log, please refer to Outputting Communication Logs later in the page.

Screen Layout and Operating Instructions

api-log

1. Communication Logs

Displays a list of the communication logs output.

  • By pressing any communication log, it will be highlighted, and the details of the selected communication are displayed on the right side of the screen. (It is displayed at the bottom in case of a portrait orientation.)
  • By long-pressing any communication log, the contents of the communication log are copied to the clipboard.
  • By pressing the selected communication log again, the details are hidden.
  • By long-pressing the [×] button on the right side of any communication log, the corresponding log will be deleted.

log-entries

ItemDescription
a. Log TypeRepresents the type of the log. Please refer to the information described later for what each color means.
b. Output TimeDisplays the time the log was output.
c. API PathDisplays the API path and query.
d. Received Byte NumberDisplays the number of received bytes.
e. Time Spent on CommunicationDisplays the time (in milliseconds) spent on communication.
f. Number of LogsDisplays the number of consecutive outputs of the same log.

2. Communication Status

Displays the number of communications, total received bytes, and total time.

Note: Displayed only if there are communication logs.

log-status

ItemDescription
a. Number of CommunicationsDisplays the number of times the API communication was performed.
b. Total Received BytesDisplays the total number of received bytes.
c. Total TimeDisplays the total time (in milliseconds) spent on communication.

3. Communication Details

Displays the details of the selected communication log. The details of the communication include the following content.

log-details

ItemDescription
a. RequestDisplays the API details, request header, and request body.
b. ResponseDisplays the response header and response body.

In the case where the Content-Type is application/json, it will format and display the request body and the response body.

If the JSON could not be correctly parsed, it will display the input text as is.

4. Communication Log Collect Button

By pressing the [●REC] button, you can toggle the collection of communication logs on and off. Communication logs are collected when the application is started.

The [●REC] button in red means collecting, while white means stopping.

5. Clear Button

By pressing [destruction] button, all retained logs will be deleted.

6. Download Button

By pressing the [download] button, a dialog to download the retained logs will be displayed. If there is no logs, you cannot press the [download] button.

Please refer to About Download for information on the download dialog.

7. Success Log Toggle

Displays the number of communications that ended with a 200-series status code. You can toggle the display and non-display of messages by pressing the [●] button.

8. Error Log Toggle

Displays the number of communications that ended with a status code other than the 200 series. You can toggle the display and non-display of messages by pressing the [●] button.

9. Search Field

The log will be filtered and displayed based on the text you input. Logs that include the matching text will be displayed.

Note: The information from the communication details is not included in the search.

10. Clear Search Text Button

By pressing the [×] button, the text entered in the search field will be cleared.

11. Scroll to Bottom Button

By pressing the [↓] button, the log list will be scrolled to the bottom.

Note: If the latest log is being displayed, the scroll-to-bottom button will not be displayed.

12. Copy Button

Pressing the [copy] button copies the contents of the communication log to the clipboard.

Note: This is the same behavior as long-pressing the log.

Log Types

Icon ColorLog Type
type-messageRepresents the communication that ended with a 200-series status code.
type-errorRepresents the communication that ended with a status code other than the 200 series.

Outputting Communication Logs

By calling NoaDebugger.ApiLogger.Log() within an application that integrates the NOA Debugger, you can display the communication log on the NOA Debugger.

The sample code for performing POST communication using UnityEngine.Networking.UnityWebRequest is shown below.

Note: When using the functions provided by the NOA Debugger, always use the symbol definition of NOA_DEBUGGER.

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
#if NOA_DEBUGGER
using NoaDebugger;
#endif
using UnityEngine;
using UnityEngine.Networking;

public class ApiLogSample : MonoBehaviour
{
    void Start()
    {
        const string endpoint = "https://example.com/api/foo";
        const string requestBodyJson = "{ \"field1\":\"1\", \"field2\":\"2\" }";
        StartCoroutine(ApiLogSample.PostJson(endpoint, requestBodyJson));
    }

    static IEnumerator PostJson(string endpoint, string requestBodyJson)
    {
        // Create a POST request.
        using var request = new UnityWebRequest(endpoint, "POST");
        var requestHeaders = new Dictionary<string, string>
        {
            { "Content-Type", "application/json" }
        };
        byte[] rawData = Encoding.UTF8.GetBytes(requestBodyJson);
        request.uploadHandler = new UploadHandlerRaw(rawData);
        request.downloadHandler = new DownloadHandlerBuffer();
        foreach (KeyValuePair<string, string> header in requestHeaders)
        {
            request.SetRequestHeader(header.Key, header.Value);
        }

        // Perform communication, and measure the time it took.
        var stopwatch = new Stopwatch();
        stopwatch.Start();
        yield return request.SendWebRequest();
        stopwatch.Stop();

#if NOA_DEBUGGER
        // Outputs logs to the NOA Debugger. Please run this before the UnityWebRequest instance is destroyed.
        var apiLog = new ApiLog
        {
            Url = request.uri,
            Method = request.method,
            StatusCode = (int)request.responseCode,
            ContentSize = (long)request.downloadedBytes,
            ResponseTimeMilliSeconds = stopwatch.ElapsedMilliseconds,
            RequestHeaders = requestHeaders,
            RequestBody = requestBodyJson,
            ResponseHeaders = request.GetResponseHeaders(),
            ResponseBody = request.downloadHandler.text
        };
        ApiLogger.Log(apiLog);
#endif
    }
}

NoaDebugger.ApiLog has the following properties:

PropertyTypeDescriptionBehavior in the Absence of Settings
UrlSystem.UriRequest destination URL.An ArgumentException occurs in ApiLogger.Log().
MethodstringRequest method.An ArgumentException occurs in ApiLogger.Log().
StatusCodeintStatus code.Will be reflected in the log as 0.
ContentSizelongData size of the response.Will be reflected in the log as 0.
ResponseTimeMilliSecondslongSpecify the time it took for the response in milliseconds.Will be reflected in the log as 0.
RequestHeadersSystem.Collections.Generic.Dictionary<string,string>Request header.Not displayed in communication details.
RequestBodystringRequest body.Not displayed in communication details.
ResponseHeadersSystem.Collections.Generic.Dictionary<string,string>Response header.Not displayed in communication details.
ResponseBodystringResponse body.Not displayed in communication details.

APIs provided by NOA Debugger

Please refer to the API List for the APIs provided by APILog.