Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VRChatのログ出力がオフである可能性があるとき、通知を飛ばすようにする #33

Merged
merged 8 commits into from
Mar 20, 2024
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ VRChat

4. �X�^�[�g���j���[����VRCImageHelper���N�����A�^�X�N�o�[�ɏo�Ă���A�C�R�� <img style="height:1em" src="https://github.com/m-hayabusa/VRCImageHelper/raw/master/VRCImageHelper/icon.ico"> ���E�N���b�N�A�����N���̃`�F�b�N���‚���ƁA���񂩂�PC�Ƀ��O�C�������ۂɎ����ŋN������悤�ɂȂ�

### �uVRChat�̃��O�o�͂��I�t�ɂȂ��Ă��܂��񂩁H�v����n�܂�ʒm���\�����ꂽ�ꍇ

VRChat�̐ݒ肩��A�uLogging�v��L���ɂ���K�v������”\��������̂ŁA�m�F���K�v
![image](https://github.com/m-hayabusa/VRCImageHelper/assets/10593623/b4a22571-bf88-4353-80e3-908323dd2470)

### �A���C���X�g�[��

Windows�� �ݒ�/�A�v��/�C���X�g�[������Ă���A�v�� ����A���C���X�g�[���ł��� (�����ɐݒ�t�@�C�����폜�����)
Expand Down
22 changes: 16 additions & 6 deletions VRCImageHelper/Core/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ScanAllProgressEventArgs(int processing, int total)
internal class LogReader : IDisposable
{
private readonly Timer _refreshTimer;
private readonly string _logDir;
private static readonly string s_logDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low\\VRChat\\VRChat\\";
private readonly CancellationToken _cancellationToken;
private readonly FileSystemWatcher _fsWatcher;
private FileInfo? _logFile;
Expand All @@ -38,8 +38,7 @@ internal class LogReader : IDisposable
public LogReader(CancellationToken token)
{
_cancellationToken = token;
_logDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low\\VRChat\\VRChat\\";
_fsWatcher = new FileSystemWatcher(_logDir)
_fsWatcher = new FileSystemWatcher(s_logDir)
{
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.FileName
};
Expand Down Expand Up @@ -76,7 +75,7 @@ public void Enable(bool scanAll)

var logFile = FindLogFile(null, scanAll);
var progress = 0;
var total = scanAll ? Directory.EnumerateFiles(_logDir, "output_log_*.txt", SearchOption.TopDirectoryOnly).Count() : 1;
var total = scanAll ? Directory.EnumerateFiles(s_logDir, "output_log_*.txt", SearchOption.TopDirectoryOnly).Count() : 1;
do
{
ScanAllProgress?.Invoke(this, new ScanAllProgressEventArgs(progress, total));
Expand All @@ -101,6 +100,17 @@ private void Watcher_Created(object sender, FileSystemEventArgs e)
_logFile = newLogFile;
_head = 0;
SeeqLog();

var logChk = new Timer(10000);
logChk.Elapsed += (s, e) =>
{
if (newLogFile.Exists && newLogFile.CreationTime == newLogFile.LastWriteTime)
{
UI.SendNotify.Send(Properties.Resources.NotifyErrorLogFileNotBeWritten, false);
}
logChk.Dispose();
};
logChk.Enabled = true;
}
}

Expand Down Expand Up @@ -192,9 +202,9 @@ private void SeeqLog()
_seeqLogLock = false;
}

private FileInfo? FindLogFile(FileInfo? prev = null, bool old = false)
public static FileInfo? FindLogFile(FileInfo? prev = null, bool old = false)
{
var logFiles = Directory.EnumerateFiles(_logDir, "output_log_*.txt", SearchOption.TopDirectoryOnly)
var logFiles = Directory.EnumerateFiles(s_logDir, "output_log_*.txt", SearchOption.TopDirectoryOnly)
.ToList()
.OrderBy(f => File.GetCreationTime(f));

Expand Down
4 changes: 4 additions & 0 deletions VRCImageHelper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ private static void Main()
new UI.ConfigWindow().ShowDialog();
if (VRCExifWriter.Remove())
return;
var logFile = LogReader.FindLogFile();
if (logFile != null && logFile.Exists && logFile.CreationTime == logFile.LastWriteTime) {
UI.SendNotify.Send(Properties.Resources.NotifyErrorLogFileSeemsEmptyOnSetup, false);
}
Process.Start(Application.ExecutablePath);
return;
}
Expand Down
22 changes: 22 additions & 0 deletions VRCImageHelper/Properties/Resources.Designer.cs

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

10 changes: 10 additions & 0 deletions VRCImageHelper/Properties/Resources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@
<data name="NotifyErrorImageProcessFileExist" xml:space="preserve">
<value>エラー: 保存先にファイルがすでに存在します</value>
</data>
<data name="NotifyErrorLogFileNotBeWritten" xml:space="preserve">
<value>VRChatのログ出力がオフになっていませんか?
VRChatのログファイルに10秒間何も書き込まれませんでした。
VRChat内QuickMenu最下部 Debug セクションの Logging を有効にしないと、このプログラムは正しく動作しません。</value>
</data>
<data name="NotifyErrorLogFileSeemsEmptyOnSetup" xml:space="preserve">
<value>VRChatのログ出力がオフになっていませんか?
最後にVRChatを起動したときのログファイルに何も書き込まれていないようです。
VRChat内QuickMenu最下部 Debug セクションの Logging を有効にしないと、このプログラムは正しく動作しません。</value>
</data>
<data name="ScanAllRestartMessage" xml:space="preserve">
<value>過去のVRChatのログについて、さかのぼって処理を実行しますか?
処理が終わるまではOSCメッセージが無視されます。</value>
Expand Down
10 changes: 10 additions & 0 deletions VRCImageHelper/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ Do you want to download it?</value>
<data name="NotifyErrorImageProcessFileExist" xml:space="preserve">
<value>Error: Destination file has exist</value>
</data>
<data name="NotifyErrorLogFileNotBeWritten" xml:space="preserve">
<value>Check VRChat's log output is enabled.
Nothing was written to the VRChat's log file for 10 seconds.
This program will not work if that is disabled. Enable "Logging" in the Debug section at the bottom of the Quick Menu of VRChat.</value>
</data>
<data name="NotifyErrorLogFileSeemsEmptyOnSetup" xml:space="preserve">
<value>Check VRChat's log output is enabled.
Last log file of the VRChat seems empty.
This program will not work if that is disabled. Enable "Logging" in the Debug section at the bottom of the Quick Menu of VRChat.</value>
</data>
<data name="ScanAllRestartMessage" xml:space="preserve">
<value>Do you want to retroactively perform processing on past VRChat logs?
OSC messages will discard until complete that.</value>
Expand Down