using FishNet.Documenting;
using FishNet.Managing.Logging;
using System.Runtime.CompilerServices;
using UnityEngine;
namespace FishNet.Managing
{
public partial class NetworkManager : MonoBehaviour
{
#region Serialized.
///
/// Logging configuration to use. When empty default logging settings will be used.
///
[Tooltip("Logging configuration to use. When empty default logging settings will be used.")]
[SerializeField]
private LoggingConfiguration _logging;
#endregion
#region Const.
private const string ERROR_LOGGING_PREFIX = "Error - ";
private const string WARNING_LOGGING_PREFIX = "Warning - ";
private const string COMMON_LOGGING_PREFIX = "Log - ";
#endregion
///
/// Initializes logging settings.
///
private void InitializeLogging()
{
if (_logging == null)
_logging = ScriptableObject.CreateInstance();
else
_logging = _logging.Clone();
_logging.InitializeOnce();
}
///
/// True if can log for loggingType.
///
///
///
[APIExclude]
public static bool StaticCanLog(LoggingType loggingType)
{
NetworkManager nm = InstanceFinder.NetworkManager;
return (nm == null) ? false : nm.CanLog(loggingType);
}
///
/// True if can log for loggingType.
///
/// Type of logging being filtered.
///
public bool CanLog(LoggingType loggingType)
{
return _logging.CanLog(loggingType);
}
///
/// Performs a common log, should logging settings permit it.
///
[APIExclude]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void StaticLog(string value) => InstanceFinder.NetworkManager?.Log(value);
///
/// Performs a common log, should logging settings permit it.
///
public void Log(string value)
{
_logging.Log(value);
}
///
/// Performs a log using the loggingType, should logging settings permit it.
///
public void Log(LoggingType loggingType, string value)
{
if (loggingType == LoggingType.Common)
_logging.Log(value);
else if (loggingType == LoggingType.Warning)
_logging.LogWarning(value);
else if (loggingType == LoggingType.Error)
_logging.LogError(value);
}
///
/// Performs a warning log, should logging settings permit it.
///
///
[APIExclude]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void StaticLogWarning(string value) => InstanceFinder.NetworkManager?.LogWarning(value);
///
/// Performs a warning log, should logging settings permit it.
///
public void LogWarning(string value)
{
_logging.LogWarning(value);
}
///
/// Performs an error log, should logging settings permit it.
///
[APIExclude]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void StaticLogError(string value) => InstanceFinder.NetworkManager?.LogError(value);
///
/// Performs an error log, should logging settings permit it.
///
public void LogError(string value)
{
_logging.LogError(value);
}
}
}