Clean project layout and fix release workflow
Some checks failed
build-windows-exe / build (push) Failing after 1m13s

This commit is contained in:
messypy
2026-07-27 23:01:24 +09:00
parent 3ff33e40e3
commit dd165d9301
80 changed files with 2908 additions and 5661 deletions

View File

@@ -26,18 +26,50 @@ func (w *runtimeLogWriter) Write(p []byte) (int, error) {
return w.file.Write(p)
}
func (w *runtimeLogWriter) ensureFile(path string) error {
w.mu.Lock()
defer w.mu.Unlock()
if w.file != nil {
return nil
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
return err
}
w.file = f
return nil
}
func (w *runtimeLogWriter) appendf(path, format string, args ...any) error {
w.mu.Lock()
defer w.mu.Unlock()
if w.file == nil {
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
return err
}
w.file = f
}
_, err := fmt.Fprintf(w.file, format, args...)
return err
}
var runtimeLogFileWriter runtimeLogWriter
var joinLeaveLogFileWriter runtimeLogWriter
var desktopJoinLogMu sync.Mutex
var desktopJoinLogLastPath string
var desktopJoinLogLastBody string
func setupRuntimeLogger() error {
dir := filepath.Join(common.RootDir(), "runtime")
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
path := filepath.Join(dir, "runtime.log")
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
if err := runtimeLogFileWriter.ensureFile(path); err != nil {
return err
}
logWriter := &runtimeLogWriter{file: f}
log.SetOutput(io.MultiWriter(os.Stderr, logWriter))
log.SetOutput(io.MultiWriter(os.Stderr, &runtimeLogFileWriter))
return nil
}
@@ -51,13 +83,7 @@ func appendRuntimeLog(title, text string) error {
if body == "" {
body = "(empty)"
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
return err
}
defer f.Close()
_, err = fmt.Fprintf(f, "\n[%s] %s\n%s\n", time.Now().Format("2006-01-02 15:04:05"), title, body)
return err
return runtimeLogFileWriter.appendf(path, "\n[%s] %s\n%s\n", time.Now().Format("2006-01-02 15:04:05"), title, body)
}
func AppendRuntimeLog(title, text string) error {
@@ -74,13 +100,7 @@ func appendJoinLeaveLog(text string) error {
if body == "" {
body = "(empty)"
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil {
return err
}
defer f.Close()
_, err = fmt.Fprintf(f, "\n[%s] VRC JOIN/LEAVE\n%s\n", time.Now().Format("2006-01-02 15:04:05"), body)
return err
return joinLeaveLogFileWriter.appendf(path, "\n[%s] VRC JOIN/LEAVE\n%s\n", time.Now().Format("2006-01-02 15:04:05"), body)
}
func appendDesktopJoinLog(title, worldLabel, text string) error {
@@ -101,6 +121,11 @@ func appendDesktopJoinLog(title, worldLabel, text string) error {
if body == "" {
body = "(empty)"
}
desktopJoinLogMu.Lock()
defer desktopJoinLogMu.Unlock()
if desktopJoinLogLastPath == path && desktopJoinLogLastBody == body {
return nil
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {
fallbackDir := filepath.Join(common.RootDir(), "runtime")
@@ -115,8 +140,12 @@ func appendDesktopJoinLog(title, worldLabel, text string) error {
path = fallbackPath
}
defer f.Close()
_, err = fmt.Fprintf(f, "%s\nWorld: %s\n\n%s\n", title, worldLabel, body)
return err
if _, err = fmt.Fprintf(f, "%s\n", body); err != nil {
return err
}
desktopJoinLogLastPath = path
desktopJoinLogLastBody = body
return nil
}
func AppendDesktopJoinLog(title, worldLabel, text string) error {