NoaDebuggerNoaDebugger
  • 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.

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.

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. RequestDisplays the number of times the API communication was performed.
b. SizeDisplays the total number of received bytes.
c. 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. HeadersDisplays the API details, response header, request header, and request body.
b. ResponseDisplays the response body.

Specify whether to format and display the request body and response body in the properties of the NoaDebugger.ApiLog class. For more details, see the information below.

You can adjust the display area by dragging the boundary between the communication log list and the communication detail.

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. Log Selection Toggle

By pressing the [Log Selection] button, you can toggle the log selection mode. For details about the log selection mode, please refer to the information described later. Additionally, the number of selected logs will be displayed.

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 Display Toggle

By pressing the [Search] button, the search field will be displayed.

10. 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.

11. Clear Search Text Button

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

12. 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.

13. 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 Selection Mode

Switch to Log Selection Mode using the Log Selection Toggle. In Log Selection Mode, you can select multiple logs and perform download or send operations on the selected logs.

api-log-selection

1. Log

Press a log to select the target log.

2. Select All

By pressing the [select-all Select All] button, select all logs at once.

3. Deselect All

By pressing the [deselect-all Deselect All] button, deselect all logs at once.

4. Download Button

By pressing the [download] button, a dialog to download the selected 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.

5. Send Button

By pressing the [send Send] button to execute the "OnLogSend" callback. The list of selected logs will be passed as an argument to "OnLogSend". For details on "OnLogSend", refer to API List.

If there is no log information or the callback is not registered, you cannot press the [send Send] button.

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.

About the Overlay Feature

Screen UI Layout

View

Settings Screen

Settings

1. Display Settings

When these settings are changed, they will be kept even if you restart the app.

If the values are not retained, the default values specified in Tool Settings will be applied.

ItemDescription
PositionSpecifies the position of the overlay.
Font ScaleSpecifies the font scale for overlay logs within a range of 0.5 to 1.5.
Maximum Log CountSpecifies the maximum number of log displayed in the overlay, within a range of 10 to 30.
Minimum OpacitySpecifies the minimum opacity of the overlay in the range from 0.0 to 1.0
Active DurationSpecifies the active duration of the overlay within a range of 1 to 5 seconds.
The overlay will be fade out automatically after the specified number of seconds have elapsed since the last log output.
Show TimestampSpecifies whether to display timestamps in the overlay logs.
Show Message LogsSpecifies whether to display message logs on the overlay.
Show Error LogsSpecifies whether to display error logs on the overlay.

2. Reset Button

Pressing the [Reset] button discards the saved settings for the APILog overlay and applies the default values.

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,
            PrettyPrint = true
        };
        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.
RequestBodyRawDataobjectRequest body before conversion. The conversion will be executed when displaying the API log, and the result will be assigned to RequestBody.Applies RequestBody without performing the conversion.
ResponseHeadersSystem.Collections.Generic.Dictionary<string,string>Response header.Not displayed in communication details.
ResponseBodystringResponse body.Not displayed in communication details.
ResponseBodyRawDataobjectResponse body before conversion. The conversion will be executed when displaying the API log, and the result will be assigned to ResponseBody.Applies ResponseBody without performing the conversion.
PrettyPrintboolSpecify whether to format the request body and response body if they are in JSON format. If false or not in JSON format, the entered text will be displayed as is.Formatting will be executed.

If registering data before converting to a string

By registering the conversion process in NoaDebugger.ApiLogger.OnConvertRequestBodyToString or NoaDebugger.ApiLogger.OnConvertResponseBodyToString, you can register the request body and response body as RawData in types other than string.

The conversion process is executed only once, and after execution, the RawData is discarded.

The sample code for converting the request body and response body from RawData is shown below.

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\" }";
        // Pre-register the conversion process. One-time registration is sufficient.
        // It will be executed only when the corresponding RawData has been registered.
        ApiLogger.OnConvertRequestBodyToString = rawData => Encoding.UTF8.GetString(((UploadHandlerRaw)rawData).data);
        ApiLogger.OnConvertResponseBodyToString = rawData => ((DownloadHandlerBuffer)rawData).text;
        StartCoroutine(ApiLogSample.PostJson(endpoint, requestBodyJson));
    }

    static IEnumerator PostJson(string endpoint, string requestBodyJson)
    {
        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();
        // Ensure that the Handler is not destroyed even if the UnityWebRequest instance is destroyed.
        request.disposeUploadHandlerOnDispose = false;
        request.disposeDownloadHandlerOnDispose = false;

        foreach (KeyValuePair<string, string> header in requestHeaders)
        {
            request.SetRequestHeader(header.Key, header.Value);
        }

        var stopwatch = new Stopwatch();
        stopwatch.Start();
        yield return request.SendWebRequest();
        stopwatch.Stop();

#if NOA_DEBUGGER
        var apiLog = new ApiLog
        {
            Url = request.uri,
            Method = request.method,
            StatusCode = (int)request.responseCode,
            ContentSize = (long)request.downloadedBytes,
            ResponseTimeMilliSeconds = stopwatch.ElapsedMilliseconds,
            RequestHeaders = requestHeaders,
            // Register the value used for the conversion in RawData.
            RequestBodyRawData = request.uploadHandler,
            ResponseHeaders = request.GetResponseHeaders(),
            ResponseBodyRawData = request.downloadHandler,
            PrettyPrint = true
        };
        ApiLogger.Log(apiLog);
#endif
    }
}

APIs provided by NOA Debugger

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