using System;
using Robust.Shared.IoC;
namespace Robust.Shared.Log
{
///
/// Static logging API front end.
/// This is here as a convenience to prevent the need to resolve the manager manually.
///
///
/// This type is simply a proxy to an IoC based and its sawmills.
/// As such, no methods or properties will work if IoC has not been initialized yet.
///
///
///
public static class Logger
{
///
/// The instance we're using.
/// As it's a direct proxy to IoC this will not work if IoC is not functional.
///
// TODO: Maybe cache this to improve performance.
private static ILogManager LogManagerSingleton => IoCManager.Resolve();
///
/// Gets a sawmill by name. Equivalent to .
///
/// The name of the sawmill to get.
/// The sawmill with specified name. Creates a new one if it does not exist.
public static ISawmill GetSawmill(string name)
{
return LogManagerSingleton.GetSawmill(name);
}
///
/// Log a message, taking in a format string and format list using the regular syntax.
///
public static void LogS(LogLevel logLevel, string sawmillname, string message, params object?[] args)
{
var sawmill = LogManagerSingleton.GetSawmill(sawmillname);
sawmill.Log(logLevel, message, args);
}
///
/// Log a message, taking in a format string and format list using the regular syntax.
///
public static void LogS(LogLevel logLevel, string sawmillname, Exception? exception, string message, params object?[] args)
{
var sawmill = LogManagerSingleton.GetSawmill(sawmillname);
sawmill.Log(logLevel, exception, message, args);
}
///
/// Log a message.
///
public static void LogS(LogLevel logLevel, string sawmillname, string message)
{
var sawmill = LogManagerSingleton.GetSawmill(sawmillname);
sawmill.Log(logLevel, message);
}
///
/// Log a message, taking in a format string and format list using the regular syntax.
///
public static void Log(LogLevel logLevel, string message, params object?[] args)
{
LogManagerSingleton.RootSawmill.Log(logLevel, message, args);
}
public static void Log(LogLevel logLevel, Exception exception, string message, params object?[] args)
{
LogManagerSingleton.RootSawmill.Log(logLevel, message, args);
}
///
/// Log a message.
///
public static void Log(LogLevel logLevel, string message)
{
LogManagerSingleton.RootSawmill.Log(logLevel, message);
}
///
/// Log a message as debug, taking in a format string and format list using the regular syntax.
///
///
public static void DebugS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Debug, sawmill, message, args);
///
/// Log a message as debug.
///
///
public static void DebugS(string sawmill, string message) => LogS(LogLevel.Debug, sawmill, message);
///
/// Log a message as debug, taking in a format string and format list using the regular syntax.
///
///
public static void Debug(string message, params object?[] args) => Log(LogLevel.Debug, message, args);
///
/// Log a message as debug.
///
///
public static void Debug(string message) => Log(LogLevel.Debug, message);
///
/// Log a message as info, taking in a format string and format list using the regular syntax.
///
///
public static void InfoS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Info, sawmill, message, args);
///
/// Log a message as info.
///
///
public static void InfoS(string sawmill, string message) => LogS(LogLevel.Info, sawmill, message);
///
/// Log a message as info, taking in a format string and format list using the regular syntax.
///
///
public static void Info(string message, params object?[] args) => Log(LogLevel.Info, message, args);
///
/// Log a message as info.
///
///
public static void Info(string message) => Log(LogLevel.Info, message);
///
/// Log a message as warning, taking in a format string and format list using the regular syntax.
///
///
public static void WarningS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Warning, sawmill, message, args);
///
/// Log a message as warning.
///
///
public static void WarningS(string sawmill, string message) => LogS(LogLevel.Warning, sawmill, message);
///
/// Log a message as warning, taking in a format string and format list using the regular syntax.
///
///
public static void Warning(string message, params object?[] args) => Log(LogLevel.Warning, message, args);
///
/// Log a message as warning.
///
///
public static void Warning(string message) => Log(LogLevel.Warning, message);
///
/// Log a message as error, taking in a format string and format list using the regular syntax.
///
///
public static void ErrorS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Error, sawmill, message, args);
///
/// Log a message as error, taking in a format string and format list using the regular syntax.
///
///
public static void ErrorS(string sawmill, Exception exception, string message, params object?[] args) => LogS(LogLevel.Error, sawmill, exception, message, args);
///
/// Log a message as error.
///
///
public static void ErrorS(string sawmill, string message) => LogS(LogLevel.Error, sawmill, message);
///
/// Log a message as error, taking in a format string and format list using the regular syntax.
///
///
public static void Error(string message, params object?[] args) => Log(LogLevel.Error, message, args);
///
/// Log a message as error.
///
///
public static void Error(string message) => Log(LogLevel.Error, message);
///
/// Log a message as fatal, taking in a format string and format list using the regular syntax.
///
///
public static void FatalS(string sawmill, string message, params object?[] args) => LogS(LogLevel.Fatal, sawmill, message, args);
///
/// Log a message as fatal.
///
///
public static void FatalS(string sawmill, string message) => LogS(LogLevel.Fatal, sawmill, message);
///
/// Log a message as fatal, taking in a format string and format list using the regular syntax.
///
///
public static void Fatal(string message, params object?[] args) => Log(LogLevel.Fatal, message, args);
///
/// Log a message as fatal.
///
///
public static void Fatal(string message) => Log(LogLevel.Fatal, message);
}
}