Skip to content

Commit

Permalink
resolve #1, resolve #2, resolve #3
Browse files Browse the repository at this point in the history
  • Loading branch information
uurha committed Feb 23, 2024
1 parent f8508c5 commit afb83f3
Show file tree
Hide file tree
Showing 27 changed files with 535 additions and 36 deletions.
8 changes: 8 additions & 0 deletions Assets/Better.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Better/Logger.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Better/Logger/Resources.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Assets/Better/Logger/Resources/LoggerSettings.asset

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Better/Logger/Resources/LoggerSettings.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Assets/BetterLogger/Editor/BetterLogger.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "BetterLogger.Editor",
"rootNamespace": "Better.Logger.EditorAddons",
"references": [
"GUID:a19d71ac5231b4a45a527dfc93a21f58"
"GUID:a19d71ac5231b4a45a527dfc93a21f58",
"GUID:19891d5296046644cbc12fcf3702cca3",
"GUID:a59e3daedde9ca94bba45364d4ead25f"
],
"includePlatforms": [
"Editor"
Expand Down
3 changes: 3 additions & 0 deletions Assets/BetterLogger/Editor/Settings.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Assets/BetterLogger/Editor/Settings/LoggerSettingsTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Better.EditorTools.SettingsTools;
using Better.Logger.Runtime.Settings;
using Better.Tools.Runtime;

namespace Better.Logger.EditorAddons.Settings
{
public class LoggerSettingsTool : ProjectSettingsTools<LoggerSettings>
{
private const string SettingMenuItem = nameof(Logger);
public const string MenuItemPrefix = BetterEditorDefines.BetterPrefix + "/" + SettingMenuItem;

public LoggerSettingsTool() : base(SettingMenuItem, SettingMenuItem)
{
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/BetterLogger/Editor/Settings/ValidationSettingProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using Better.EditorTools.SettingsTools;
using Better.Logger.Runtime.Settings;
using Better.Tools.Runtime;
using UnityEditor;

namespace Better.Logger.EditorAddons.Settings
{
internal class ValidationSettingProvider : ProjectSettingsProvider<LoggerSettings>
{
private readonly Editor _editor;

public ValidationSettingProvider() : base(ProjectSettingsToolsContainer<LoggerSettingsTool>.Instance, SettingsScope.Project)
{
keywords = new HashSet<string>(new[] { "Better", "Logger", "Warnings", "Debug", "Error", "Exception", "Ignore", "Log" });
_editor = Editor.CreateEditor(_settings);
}

[MenuItem(LoggerSettingsTool.MenuItemPrefix + "/" + BetterEditorDefines.HighlightPrefix, false, 999)]
private static void Highlight()
{
SettingsService.OpenProjectSettings(ProjectSettingsToolsContainer<LoggerSettingsTool>.Instance.ProjectSettingKey);
}

protected override void DrawGUI()
{
_editor.OnInspectorGUI();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Assets/BetterLogger/Runtime/BetterLogger.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "BetterLogger.Runtime",
"rootNamespace": "Better.Logger.Runtime",
"references": [],
"references": [
"GUID:a59e3daedde9ca94bba45364d4ead25f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
Expand Down
215 changes: 201 additions & 14 deletions Assets/BetterLogger/Runtime/Logger/BetterLogger.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,209 @@
using System.Collections;
using System.Collections.Generic;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using Better.Logger.Runtime;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;

namespace Better.Logger.Runtime
public static class BetterLogger
{
public static class BetterLogger
{
[DebuggerHidden][DebuggerNonUserCode]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Log(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{

}

#region Log

[DebuggerHidden]
[DebuggerNonUserCode]
public static void Log(string message)
{
LogTypeInternal(LogType.Log, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void Log(object message)
{
LogTypeInternal(LogType.Log, message, null);
}

[DebuggerNonUserCode]
public static void Log(string message, Object context)
{
LogTypeInternal(LogType.Log, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void Log(object message, Object context)
{
LogTypeInternal(LogType.Log, message, context);
}

#endregion

#region Warning

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogWarning(string message)
{
LogTypeInternal(LogType.Warning, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogWarning(object message)
{
LogTypeInternal(LogType.Warning, message, null);
}

[DebuggerNonUserCode]
public static void LogWarning(string message, Object context)
{
LogTypeInternal(LogType.Warning, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogWarning(object message, Object context)
{
LogTypeInternal(LogType.Warning, message, context);
}

#endregion

#region Error

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogError(string message)
{
LogTypeInternal(LogType.Error, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogError(object message)
{
LogTypeInternal(LogType.Error, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogError(string message, Object context)
{
LogTypeInternal(LogType.Error, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogError(object message, Object context)
{
LogTypeInternal(LogType.Error, message, context);
}

#endregion

#region Exception

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(Exception exception)
{
LogExceptionInternal(exception, exception.Message,null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(Exception exception, Object context)
{
LogExceptionInternal(exception, exception.Message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException<T>(object message) where T : Exception, new()
{
var exception = new T();
LogExceptionInternal(exception, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException<T>(object message, Object context) where T : Exception, new()
{
var exception = new T();
LogExceptionInternal(exception, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException<T>(string message) where T : Exception, new()
{
var exception = new T();
LogExceptionInternal(exception, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException<T>(string message, Object context) where T : Exception, new()
{
var exception = new T();
LogExceptionInternal(exception, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(object message)
{
var exception = new Exception();
LogExceptionInternal(exception, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(object message, Object context)
{
var exception = new Exception();
LogExceptionInternal(exception, message, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(string message)
{
var exception = new Exception();
LogExceptionInternal(exception, message, null);
}

[DebuggerHidden]
[DebuggerNonUserCode]
public static void LogException(string message, Object context)
{
var exception = new Exception();
LogExceptionInternal(exception, message, context);
}

#endregion

#region Internal

[DebuggerHidden]
[DebuggerNonUserCode]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void LogExceptionInternal(Exception exception, object message, Object context)
{
LogBuilder.BuildLogException(exception, message);
Debug.unityLogger.LogException(exception, context);
}

[DebuggerHidden]
[DebuggerNonUserCode]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void LogTypeInternal(LogType logType, object message, Object context)
{
Debug.unityLogger.Log(logType, LogBuilder.BuildLogObject(message), context);
}

#endregion
}
Loading

0 comments on commit afb83f3

Please sign in to comment.