using System;
using System.Runtime.CompilerServices;
namespace BepInEx
{
///
/// A helper class to use for logging.
///
public static class BepInLogger
{
///
/// The handler for a entry logged event.
///
/// The text element of the log itself.
/// Whether or not it should be dislpayed to the user.
public delegate void EntryLoggedEventHandler(string entry, bool show = false);
///
/// The listener event for an entry being logged.
///
public static event EntryLoggedEventHandler EntryLogged;
///
/// Logs an entry to the logger, and any listeners are notified of the entry.
///
/// The text element of the log itself.
/// Whether or not it should be dislpayed to the user.
public static void Log(string entry, bool show = false)
{
UnityEngine.UnityLogWriter.WriteStringToUnityLog($"BEPIN - {entry}\r\n");
Console.WriteLine(entry);
EntryLogged?.Invoke(entry, show);
}
}
}
namespace UnityEngine
{
internal sealed class UnityLogWriter
{
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void WriteStringToUnityLog(string s);
}
}