Skip to content

Commit

Permalink
Fix renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed May 9, 2024
1 parent 14ccee4 commit 2b7a566
Show file tree
Hide file tree
Showing 23 changed files with 119 additions and 123 deletions.
6 changes: 3 additions & 3 deletions Editor/UI/Loggers/CompositeLoggerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace DeNA.Anjin.Editor.UI.Loggers
/// <summary>
/// Editor GUI for CompositeLogger.
/// </summary>
[CustomEditor(typeof(CompositeLogger))]
[CustomEditor(typeof(CompositeLoggerSettings))]
public class CompositeLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
Expand All @@ -24,9 +24,9 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLogger.description)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLoggerSettings.description)),
new GUIContent(s_description, s_descriptionTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLogger.loggers)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLoggerSettings.loggerSettings)),
new GUIContent(s_loggers, s_loggersTooltip));

serializedObject.ApplyModifiedProperties();
Expand Down
6 changes: 3 additions & 3 deletions Editor/UI/Loggers/ConsoleLoggerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace DeNA.Anjin.Editor.UI.Loggers
/// <summary>
/// Editor GUI for ConsoleLogger.
/// </summary>
[CustomEditor(typeof(ConsoleLogger))]
[CustomEditor(typeof(ConsoleLoggerSettings))]
public class ConsoleLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
Expand All @@ -24,9 +24,9 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(ConsoleLogger.description)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(ConsoleLoggerSettings.description)),
new GUIContent(s_description, s_descriptionTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(ConsoleLogger.filterLogType)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(ConsoleLoggerSettings.filterLogType)),
new GUIContent(s_filterLogType, s_filterLogTypeTooltip));

serializedObject.ApplyModifiedProperties();
Expand Down
10 changes: 5 additions & 5 deletions Editor/UI/Loggers/FileLoggerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace DeNA.Anjin.Editor.UI.Loggers
/// <summary>
/// Editor GUI for FileLogger.
/// </summary>
[CustomEditor(typeof(FileLogger))]
[CustomEditor(typeof(FileLoggerSettings))]
public class FileLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
Expand All @@ -30,13 +30,13 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLogger.description)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLoggerSettings.description)),
new GUIContent(s_description, s_descriptionTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLogger.outputPath)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLoggerSettings.outputPath)),
new GUIContent(s_outputPath, s_outputPathTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLogger.filterLogType)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLoggerSettings.filterLogType)),
new GUIContent(s_filterLogType, s_filterLogTypeTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLogger.timestamp)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(FileLoggerSettings.timestamp)),
new GUIContent(s_timestamp, s_timestampTooltip));

serializedObject.ApplyModifiedProperties();
Expand Down
2 changes: 1 addition & 1 deletion Editor/UI/Settings/AutopilotSettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public override void OnInspectorGUI()
new GUIContent(s_timeScale, s_timeScaleTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.junitReportPath)),
new GUIContent(s_junitReportPath, s_junitReportPathTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.logger)),
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.loggerSettings)),
new GUIContent(s_logger, s_loggerTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.reporter)),
new GUIContent(s_reporter, s_reporterTooltip));
Expand Down
14 changes: 5 additions & 9 deletions Runtime/Autopilot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections;
using System.Threading;
using Cysharp.Threading.Tasks;
using DeNA.Anjin.Loggers;
using DeNA.Anjin.Settings;
using DeNA.Anjin.Utilities;
using UnityEngine;
Expand All @@ -18,6 +19,7 @@ namespace DeNA.Anjin
/// </summary>
public class Autopilot : MonoBehaviour
{
private AbstractLoggerSettings _loggerSettings;
private ILogger _logger;
private RandomFactory _randomFactory;
private IAgentDispatcher _dispatcher;
Expand All @@ -32,14 +34,8 @@ private void Start()
_settings = _state.settings;
Assert.IsNotNull(_settings);

if (_settings.logger != null)
{
_logger = _settings.logger.LoggerImpl;
}
else
{
_logger = CreateDefaultLogger();
}
_loggerSettings = _settings.loggerSettings;
_logger = _loggerSettings != null ? _loggerSettings.Logger : CreateDefaultLogger();

if (!int.TryParse(_settings.randomSeed, out var seed))
{
Expand Down Expand Up @@ -99,7 +95,7 @@ private void OnDestroy()

_dispatcher?.Dispose();
_logMessageHandler?.Dispose();
_settings.logger?.Dispose();
_loggerSettings?.Dispose();
}

/// <summary>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
namespace DeNA.Anjin.Loggers
{
/// <summary>
/// A class for a logger that delegates to multiple loggers
/// A class for a logger settings that delegates to multiple loggers
/// </summary>
[CreateAssetMenu(fileName = "New CompositeLogger", menuName = "Anjin/Composite Logger", order = 70)]
public class CompositeLogger : AbstractLogger
public class CompositeLoggerSettings : AbstractLoggerSettings
{
/// <summary>
/// Loggers to delegates
/// Logger settings to delegates
/// </summary>
public List<AbstractLogger> loggers = new List<AbstractLogger>();
public List<AbstractLoggerSettings> loggerSettings = new List<AbstractLoggerSettings>();

private CompositeLogHandler _handler;
private Logger _logger;

/// <inheritdoc />
public override ILogger LoggerImpl
public override ILogger Logger
{
get
{
Expand All @@ -33,7 +33,7 @@ public override ILogger LoggerImpl
return _logger;
}

_handler = new CompositeLogHandler(loggers, this);
_handler = new CompositeLogHandler(loggerSettings, this);
_logger = new Logger(_handler);
return _logger;
}
Expand All @@ -42,42 +42,42 @@ public override ILogger LoggerImpl
/// <inheritdoc />
public override void Dispose()
{
((CompositeLogHandler)LoggerImpl.logHandler).Dispose();
_handler.Dispose();
}

private class CompositeLogHandler : ILogHandler, IDisposable
{
private readonly List<AbstractLogger> _loggers;
private readonly AbstractLogger _owner;
private readonly List<AbstractLoggerSettings> _loggerSettings;
private readonly AbstractLoggerSettings _owner;

public CompositeLogHandler(List<AbstractLogger> loggers, AbstractLogger owner)
public CompositeLogHandler(List<AbstractLoggerSettings> loggerSettings, AbstractLoggerSettings owner)
{
_loggers = loggers;
_loggerSettings = loggerSettings;
_owner = owner;
}

/// <inheritdoc />
public void LogFormat(LogType logType, Object context, string format, params object[] args)
{
foreach (var logger in _loggers.Where(logger => logger != null && logger != _owner))
foreach (var logger in _loggerSettings.Where(logger => logger != null && logger != _owner))
{
logger.LoggerImpl.LogFormat(logType, context, format, args);
logger.Logger.LogFormat(logType, context, format, args);
}
}

/// <inheritdoc />
public void LogException(Exception exception, Object context)
{
foreach (var logger in _loggers.Where(logger => logger != null && logger != _owner))
foreach (var logger in _loggerSettings.Where(logger => logger != null && logger != _owner))
{
logger.LoggerImpl.LogException(exception, context);
logger.Logger.LogException(exception, context);
}
}

/// <inheritdoc />
public void Dispose()
{
foreach (var logger in _loggers.Where(logger => logger != null && logger != _owner))
foreach (var logger in _loggerSettings.Where(logger => logger != null && logger != _owner))
{
logger.Dispose();
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
namespace DeNA.Anjin.Loggers
{
/// <summary>
/// A Logger that outputs to a console.
/// A Logger settings that outputs to a console.
/// Logger using <c>Debug.unityLogger</c>
/// </summary>
[CreateAssetMenu(fileName = "New ConsoleLogger", menuName = "Anjin/Console Logger", order = 71)]
public class ConsoleLogger : AbstractLogger
public class ConsoleLoggerSettings : AbstractLoggerSettings
{
/// <summary>
/// To selective enable debug log message.
Expand All @@ -20,7 +20,7 @@ public class ConsoleLogger : AbstractLogger
private ILogger _logger;

/// <inheritdoc />
public override ILogger LoggerImpl
public override ILogger Logger
{
get
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
namespace DeNA.Anjin.Loggers
{
/// <summary>
/// A Logger that outputs to a specified file.
/// A Logger settings that outputs to a specified file.
/// </summary>
/// <remarks>
/// If you want more functionality in the future, consider using the Unity Logging package (com.unity.logging) or ZLogger.
/// <see href="https://docs.unity3d.com/Packages/com.unity.logging@latest"/>
/// <see href="https://github.com/Cysharp/ZLogger"/>
/// </remarks>
[CreateAssetMenu(fileName = "New FileLogger", menuName = "Anjin/File Logger", order = 72)]
public class FileLogger : AbstractLogger
public class FileLoggerSettings : AbstractLoggerSettings
{
/// <summary>
/// Log output file path.
Expand All @@ -39,7 +39,7 @@ public class FileLogger : AbstractLogger
private ILogger _logger;

/// <inheritdoc />
public override ILogger LoggerImpl
public override ILogger Logger
{
get
{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Runtime/Settings/AutopilotSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class AutopilotSettings : ScriptableObject
/// <summary>
/// Logger used for this autopilot settings.
/// </summary>
public AbstractLogger logger;
public AbstractLoggerSettings loggerSettings;

/// <summary>
/// Reporter that called when some errors occurred
Expand Down
4 changes: 2 additions & 2 deletions Tests/Runtime/AutopilotTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public async Task Start_LoggerSpecified_UsingSpecifiedLogger()
var autopilotSettings = ScriptableObject.CreateInstance<AutopilotSettings>();
autopilotSettings.sceneAgentMaps = new List<SceneAgentMap>();
autopilotSettings.lifespanSec = 1;
var spyLogger = ScriptableObject.CreateInstance<SpyLogger>();
autopilotSettings.logger = spyLogger;
var spyLogger = ScriptableObject.CreateInstance<SpyLoggerSettings>();
autopilotSettings.loggerSettings = spyLogger;

await LauncherFromTest.AutopilotAsync(autopilotSettings);

Expand Down
Loading

0 comments on commit 2b7a566

Please sign in to comment.