mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-16 20:27:04 +03:00
Some checks are pending
Build docker image / build-image (push) Waiting to run
Build and Release / prepare (push) Waiting to run
Build and Release / build (386, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (386, linux, , ) (push) Blocked by required conditions
Build and Release / build (386, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, 1.21.4, win7-32) (push) Blocked by required conditions
Build and Release / build (amd64, darwin, , ) (push) Blocked by required conditions
Build and Release / build (amd64, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, linux, , ) (push) Blocked by required conditions
Build and Release / build (amd64, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, 1.21.4, win7-64) (push) Blocked by required conditions
Build and Release / build (arm, 5, linux) (push) Blocked by required conditions
Build and Release / build (arm, 6, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, freebsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, openbsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, windows) (push) Blocked by required conditions
Build and Release / build (arm64, android) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, freebsd) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / build (loong64, linux) (push) Blocked by required conditions
Build and Release / build (mips, linux) (push) Blocked by required conditions
Build and Release / build (mips64, linux) (push) Blocked by required conditions
Build and Release / build (mips64le, linux) (push) Blocked by required conditions
Build and Release / build (mipsle, linux) (push) Blocked by required conditions
Build and Release / build (ppc64, linux) (push) Blocked by required conditions
Build and Release / build (ppc64le, linux) (push) Blocked by required conditions
Build and Release / build (riscv64, linux) (push) Blocked by required conditions
Build and Release / build (s390x, linux) (push) Blocked by required conditions
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run
40 lines
796 B
Go
40 lines
796 B
Go
package log_test
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/xtls/xray-core/common"
|
|
"github.com/xtls/xray-core/common/buf"
|
|
. "github.com/xtls/xray-core/common/log"
|
|
)
|
|
|
|
func TestFileLogger(t *testing.T) {
|
|
f, err := os.CreateTemp("", "vtest")
|
|
common.Must(err)
|
|
path := f.Name()
|
|
common.Must(f.Close())
|
|
defer os.Remove(path)
|
|
|
|
creator, err := CreateFileLogWriter(path)
|
|
common.Must(err)
|
|
|
|
handler := NewLogger(creator)
|
|
handler.Handle(&GeneralMessage{Content: "Test Log"})
|
|
time.Sleep(2 * time.Second)
|
|
|
|
common.Must(common.Close(handler))
|
|
|
|
f, err = os.Open(path)
|
|
common.Must(err)
|
|
defer f.Close()
|
|
|
|
b, err := buf.ReadAllToBytes(f)
|
|
common.Must(err)
|
|
if !strings.Contains(string(b), "Test Log") {
|
|
t.Fatal("Expect log text contains 'Test Log', but actually: ", string(b))
|
|
}
|
|
}
|