Skip to content

Commit

Permalink
Merge pull request #52 from nowsprinting/feature/logger
Browse files Browse the repository at this point in the history
Pluggable loggers including FileLogger
  • Loading branch information
Kuniwak authored May 11, 2024
2 parents 5b6ff56 + b08ff4c commit 3569d22
Show file tree
Hide file tree
Showing 45 changed files with 1,273 additions and 208 deletions.
62 changes: 61 additions & 1 deletion Editor/Localization/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,21 @@ msgstr "JUnitレポート出力パス"
msgid "JUnit report output path"
msgstr "JUnit形式のレポートファイル出力パス(省略時は出力されない)"

# logger
msgid "Logger"
msgstr "ロガー"

# logger tooltip
msgid "Logger used for this autopilot settings. If omitted, Debug.unityLogger will be used as default."
msgstr "オートパイロットが使用するロガー指定します。省略時は Debug.unityLogger がデフォルトとして使用されます"

# reporter
msgid "Reporter"
msgstr "レポータ"

# reporter tooltip
msgid "Reporter that called when some errors occurred in target application"
msgstr "対象のアプリケーションで発生したエラーを通知するレポータ"
msgstr "対象のアプリケーションで発生したエラーを通知するレポータを指定します"

# obsolete slack settings
msgid "Slack settings will be moved to SlackReporter"
Expand Down Expand Up @@ -429,3 +437,55 @@ msgstr "Automated QAパッケージのRecorded Playbackウィンドウで記録
# composite reporters
msgid "Reporters"
msgstr "レポータ"


#: Editor/UI/Loggers/ 共通

# description (same as AutopilotSettingsEditor.cs)
msgid "Description"
msgstr "説明"

# description tooltip
msgid "Description about this logger instance"
msgstr "このLoggerインスタンスの説明"


#: Editor/UI/Loggers/CompositeLoggerEditor.cs

# Loggers
msgid "Loggers"
msgstr "Loggers"

# Loggers tooltip
msgid "Loggers to delegates"
msgstr "出力を委譲するLoggerを指定します"


#: Editor/UI/Loggers/ConsoleLoggerEditor.cs

# Filter LogType
msgid "Filter LogType"
msgstr "フィルタリングLogType"

# Filter LogType tooltip
msgid "To selective enable debug log message"
msgstr "選択したLogType以上のログ出力のみを有効にします"


#: Editor/UI/Loggers/FileLoggerEditor.cs

# Output Path
msgid "Output File Path"
msgstr "出力ファイルパス"

# Output Path tooltip
msgid "Log output file path. Specify relative path from project root or absolute path."
msgstr "ログ出力ファイルのパス。プロジェクトルートからの相対パスまたは絶対パスを指定します"

# Timestamp
msgid "Timestamp"
msgstr "タイムスタンプを追加"

# Timestamp tooltip
msgid "Output timestamp to log entities"
msgstr "ログエンティティにタイムスタンプを出力します"
3 changes: 3 additions & 0 deletions Editor/UI/Loggers.meta

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

35 changes: 35 additions & 0 deletions Editor/UI/Loggers/CompositeLoggerEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2023-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

using DeNA.Anjin.Loggers;
using UnityEditor;
using UnityEngine;

namespace DeNA.Anjin.Editor.UI.Loggers
{
/// <summary>
/// Editor GUI for CompositeLogger.
/// </summary>
[CustomEditor(typeof(CompositeLoggerAsset))]
public class CompositeLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
private static readonly string s_descriptionTooltip = L10n.Tr("Description about this logger instance");

private static readonly string s_loggers = L10n.Tr("Loggers");
private static readonly string s_loggersTooltip = L10n.Tr("Loggers to delegates");

/// <inheritdoc/>
public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLoggerAsset.description)),
new GUIContent(s_description, s_descriptionTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(CompositeLoggerAsset.loggerAssets)),
new GUIContent(s_loggers, s_loggersTooltip));

serializedObject.ApplyModifiedProperties();
}
}
}
3 changes: 3 additions & 0 deletions Editor/UI/Loggers/CompositeLoggerEditor.cs.meta

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

35 changes: 35 additions & 0 deletions Editor/UI/Loggers/ConsoleLoggerEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2023-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

using DeNA.Anjin.Loggers;
using UnityEditor;
using UnityEngine;

namespace DeNA.Anjin.Editor.UI.Loggers
{
/// <summary>
/// Editor GUI for ConsoleLogger.
/// </summary>
[CustomEditor(typeof(ConsoleLoggerAsset))]
public class ConsoleLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
private static readonly string s_descriptionTooltip = L10n.Tr("Description about this logger instance");

private static readonly string s_filterLogType = L10n.Tr("Filter LogType");
private static readonly string s_filterLogTypeTooltip = L10n.Tr("To selective enable debug log message");

/// <inheritdoc/>
public override void OnInspectorGUI()
{
serializedObject.Update();

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

serializedObject.ApplyModifiedProperties();
}
}
}
3 changes: 3 additions & 0 deletions Editor/UI/Loggers/ConsoleLoggerEditor.cs.meta

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

45 changes: 45 additions & 0 deletions Editor/UI/Loggers/FileLoggerEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2023-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

using DeNA.Anjin.Loggers;
using UnityEditor;
using UnityEngine;

namespace DeNA.Anjin.Editor.UI.Loggers
{
/// <summary>
/// Editor GUI for FileLogger.
/// </summary>
[CustomEditor(typeof(FileLoggerAsset))]
public class FileLoggerEditor : UnityEditor.Editor
{
private static readonly string s_description = L10n.Tr("Description");
private static readonly string s_descriptionTooltip = L10n.Tr("Description about this logger instance");

private static readonly string s_outputPath = L10n.Tr("Output File Path");
private static readonly string s_outputPathTooltip = L10n.Tr("Log output file path. Specify relative path from project root or absolute path.");

private static readonly string s_filterLogType = L10n.Tr("Filter LogType");
private static readonly string s_filterLogTypeTooltip = L10n.Tr("To selective enable debug log message");

private static readonly string s_timestamp = L10n.Tr("Timestamp");
private static readonly string s_timestampTooltip = L10n.Tr("Output timestamp to log entities");

/// <inheritdoc/>
public override void OnInspectorGUI()
{
serializedObject.Update();

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

serializedObject.ApplyModifiedProperties();
}
}
}
3 changes: 3 additions & 0 deletions Editor/UI/Loggers/FileLoggerEditor.cs.meta

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

6 changes: 6 additions & 0 deletions Editor/UI/Settings/AutopilotSettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class AutopilotSettingsEditor : UnityEditor.Editor

private static readonly string s_junitReportPath = L10n.Tr("JUnit Report Path");
private static readonly string s_junitReportPathTooltip = L10n.Tr("JUnit report output path");

private static readonly string s_logger = L10n.Tr("Logger");
private static readonly string s_loggerTooltip = L10n.Tr("Logger used for this autopilot settings. If omitted, Debug.unityLogger will be used as default.");

private static readonly string s_reporter = L10n.Tr("Reporter");
private static readonly string s_reporterTooltip = L10n.Tr("Reporter that called when some errors occurred in target application");

Expand Down Expand Up @@ -111,6 +115,8 @@ 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.loggerAsset)),
new GUIContent(s_logger, s_loggerTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.reporter)),
new GUIContent(s_reporter, s_reporterTooltip));
EditorGUILayout.HelpBox(s_obsoletedSlackParamsHelpBox, MessageType.Warning);
Expand Down
112 changes: 96 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,8 @@ This item can also be overridden from the commandline (see below).
<dt>Random Seed</dt><dd>Specify when you want to fix the seed given to the pseudo-random number generator (optional). This is a setting related to the pseudo-random number generator used by the autopilot. To fix the seed of the pseudo-random number generator in the game itself, it is necessary to implement this setting on the game title side. </dd>
<dt>Time Scale</dt><dd>Time.timeScale. Default is 1.0</dd>
<dt>JUnit Report Path</dt><dd>Specifies the JUnit format report file output path (optional). If there are zero errors and zero failures, the autopilot run is considered to have completed successfully. </dd>
<dt>Slack Token</dt><dd>Web API token used for Slack notifications (if omitted, no notifications will be sent)</dd>
<dt>Slack Channels</dt><dd>Channels to send Slack notifications (not notified if omitted. Multiple channels can be specified by separating them with commas)</dd>
</dl>

#### Slack Mention Settings

Set the mentions to be given to Slack notifications.

<dl>
<dt>Mention Sub Team IDs</dt><dd>Comma Separated Team IDs to Mention in Slack Notification Message</dd>
<dt>Add Here In Slack Message</dt><dd>Add @here to Slack notification message. Default is off</dd>
<dt>Logger</dt><dd>Logger used for this autopilot settings. If omitted, <code>Debug.unityLogger</code> will be used as default.</dd>
<dt>Reporter</dt><dd>Reporter that called when some errors occurred in target application</dd>
</dl>

#### Error Handling Settings
Expand All @@ -152,10 +143,29 @@ Set up a filter to catch abnormal log messages and notify Slack.
Whether you use the built-in Agent or implement custom Agent, you must create an instance (.asset file) of it in the Unity editor.

Instances are created by right-clicking in the Project window of the Unity editor to open the context menu, then selecting
**Create > Anjin > Agent name**.
**Create > Anjin > Agent type name**.

Select the generated file, Agent-specific settings are displayed in the inspector and can be customized.
You can prepare multiple Agents with different settings for the same Agent and use them in different Scenes.
You can prepare multiple Agents with different settings for the same Agent type and use them in different Scenes.


### Generate and configure the Logger setting file (.asset)

Logger instances are created by right-clicking in the Project window of the Unity editor to open the context menu, then selecting
**Create > Anjin > Logger type name**.

Select the generated file, Logger-specific settings are displayed in the inspector and can be customized.
You can prepare multiple Loggers with different settings for the same Logger type.


### Generate and configure the Reporter setting file (.asset)

Reporter instances are created by right-clicking in the Project window of the Unity editor to open the context menu, then selecting
**Create > Anjin > Reporter type name**.

Select the generated file, Reporter-specific settings are displayed in the inspector and can be customized.
You can prepare multiple Reporters with different settings for the same Reporter type.



## Run autopilot
Expand Down Expand Up @@ -214,8 +224,6 @@ For details on each argument, see the entry of the same name in the "Generate an
<dt>RANDOM_SEED</dt><dd>Specifies when you want to fix the seed given to the pseudo-random number generator</dd>
<dt>TIME_SCALE</dt><dd>Specifies the Time.timeScale. Default is 1.0</dd>
<dt>JUNIT_REPORT_PATH</dt><dd>Specifies the JUnit-style report file output path</dd>
<dt>SLACK_TOKEN</dt><dd>Web API token used for Slack notifications</dd>
<dt>SLACK_CHANNELS</dt><dd>Channels to send Slack notifications</dd>
</dl>

In both cases, the key should be prefixed with `-` and specified as `-LIFESPAN_SEC 60`.
Expand All @@ -224,7 +232,7 @@ In both cases, the key should be prefixed with `-` and specified as `-LIFESPAN_S

## Built-in Agents

The following Agents are provided. These can be used as they are, or project-specific Agents can be implemented and used.
The following Agent types are provided. These can be used as they are, or project-specific Agents can be implemented and used.


### UGUIMonkeyAgent
Expand Down Expand Up @@ -370,6 +378,78 @@ This can be accomplished with `ParallelCompositeAgent`, but it is easier to set



## Built-in Logger

The following Logger types are provided. These can be used as they are, or project-specific Loggers can be implemented and used.


### Composite Logger

A Logger that delegates to multiple loggers.

The instance of this Logger (.asset file) can have the following settings.

<dl>
<dt>Loggers</dt><dd>A list of Logger to delegates</dd>
</dl>


### Console Logger

A Logger that outputs to a console.

The instance of this Logger (.asset file) can have the following settings.

<dl>
<dt>Filter LogType</dt><dd>To selective enable debug log message</dd>
</dl>


### File Logger

A Logger that outputs to a specified file.

The instance of this Logger (.asset file) can have the following settings.

<dl>
<dt>Output File Path</dt><dd>Log output file path. Specify relative path from project root or absolute path. When run on player, it will be the <code>Application.persistentDataPath</code>.</dd>
<dt>Filter LogType</dt><dd>To selective enable debug log message</dd>
<dt>Timestamp</dt><dd>Output timestamp to log entities</dd>
</dl>



## Built-in Reporter

The following Reporter types are provided. These can be used as they are, or project-specific Reporters can be implemented and used.


### Composite Reporter

A Reporter that delegates to multiple Reporters.

The instance of this Reporter (.asset file) can have the following settings.

<dl>
<dt>Reporters</dt><dd>A list of Reporter to delegates</dd>
</dl>


### Slack Reporter

A Reporter that post report to Slack.

The instance of this Reporter (.asset file) can have the following settings.

<dl>
<dt>Slack Token</dt><dd>Web API token used for Slack notifications (if omitted, no notifications will be sent)</dd>
<dt>Slack Channels</dt><dd>Channels to send Slack notifications (not notified if omitted. Multiple channels can be specified by separating them with commas)</dd>
<dt>Mention Sub Team IDs</dt><dd>Comma Separated Team IDs to Mention in Slack Notification Message</dd>
<dt>Add Here In Slack Message</dt><dd>Add @here to Slack notification message. Default is off</dd>
</dl>



## Implementation of game title-specific code

Game title specific Agents and initialization code must be avoided in the release build.
Expand Down
Loading

0 comments on commit 3569d22

Please sign in to comment.