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
  • NoaConsoleLog

NoaConsoleLog

Through this class, you can obtain logs held by the ConsoleLog feature.

APIs

Static Methods

APIDescription
Add(LogType, message, stackTrace)Adds a log to be output to the ConsoleLog tool. If stackTrace is not specified, it automatically retrieves the stack trace.
Clear()Deletes all stored log information at once.

Static Properties

APIDescription
LogListReturns a list of the log information it retains.
OnErrorThis is an event that runs when an error is detected.
OnFilterErrorNotificationThis is a delegate that determines whether to display notifications when an error is detected. It will display notifications if it returns true. Please refer to the sample code for specific usage.
OnLogCopiedThis event is triggered when a log is copied to the clipboard.
OnLogDownloadThis event is triggered when a log is downloaded.
If the event handler returns true, the logs will be downloaded locally. If the event handler returns false, the logs will not be downloaded.
Note: When registering this event, the OnLogDownloadWithLogEntries event will be unregistered.
OnLogDownloadWithLogEntriesThis event is triggered when a log is downloaded.
If the event handler returns true, the logs will be downloaded locally. If the event handler returns false, the logs will not be downloaded.
Note: When registering this event, the OnLogDownload event will be unregistered.
OnLogSendThis event is triggered when a log is sent.
It fires when the [send Send] button of the ConsoleLog tool is clicked.

Sample Code

using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    void ExampleMethod()
    {
#if NOA_DEBUGGER

        // Get a list of log information retained by the ConsoleLog function.
        LinkedList<ConsoleLogEntry> consoleLogList = NoaConsoleLog.LogList;

        // Add logs to the ConsoleLog function.
        NoaConsoleLog.Add(UnityEngine.LogType.Error, "log_message", "log_stacktrace");

        // Add logs to the ConsoleLog function (without stack trace).
        NoaConsoleLog.Add(UnityEngine.LogType.Error, "log_message");

        // Add logs from a background thread.
        Task.Run(() => NoaConsoleLog.Add(UnityEngine.LogType.Error, "log_message"));

        // Set an event to be executed when an error is detected.
        NoaConsoleLog.OnError += (ConsoleLogEntry log) => Debug.Log("Error detected.");

        // Set a delegate to determine whether to display notifications when an error is detected.
        NoaConsoleLog.OnFilterErrorNotification += (ConsoleLogEntry log) => log.LogString.StartsWith("Log to notify an error.");

        // Set up the event that is triggered when a log is copied to the clipboard.
        NoaConsoleLog.OnLogCopied += (ConsoleLogEntry log, string clipboardText) => Debug.Log($"Log copied. Clipboard: {clipboardText}");

        // Set up the event that is triggered when a log is downloaded.
        NoaConsoleLog.OnLogDownload += (string filename, string jsonData) =>
        {
            Debug.Log($"Logs download. Filename: {filename}");
            // Return true to allow local download.
            // Return false to prevent local download.
            return true;
        };

        // Set up the event that is triggered when a log is downloaded.(To retrieve log information)
        NoaConsoleLog.OnLogDownloadWithLogEntries += (string filename, List<ConsoleLogEntry> logList) =>
        {
            Debug.Log($"Logs download. Filename: {filename}");
            // Return true to allow local download.
            // Return false to prevent local download.
            return true;
        };

        // Set up the event that is triggered when a log is sent.
        NoaConsoleLog.OnLogSend += (List<ConsoleLogEntry> logList) => Debug.Log("Log sent.");

        // Delete all logs.
        NoaConsoleLog.Clear();
#endif
    }
}