diff --git a/DEPS.bzl b/DEPS.bzl index 367cba15ca93c..b0d241e5f30fc 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -5893,13 +5893,13 @@ def go_deps(): name = "com_github_pingcap_log", build_file_proto_mode = "disable_global", importpath = "github.com/pingcap/log", - sha256 = "ecdf624669a639a91f49a368f7090df11e9bff366f404fc8a379035fb4d9fe7f", - strip_prefix = "github.com/pingcap/log@v1.1.1-0.20241212030209-7e3ff8601a2a", + sha256 = "8c5ac751f87626274ace3b615ff7b88552eede51c58eddb6c1f0a7ba5b191c6e", + strip_prefix = "github.com/pingcap/log@v1.1.1-0.20250424032633-85a82d016f84", urls = [ - "http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip", - "http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip", - "https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip", - "https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20241212030209-7e3ff8601a2a.zip", + "http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip", + "http://ats.apps.svc/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip", + "https://cache.hawkingrei.com/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip", + "https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/log/com_github_pingcap_log-v1.1.1-0.20250424032633-85a82d016f84.zip", ], ) go_repository( diff --git a/dumpling/log/BUILD.bazel b/dumpling/log/BUILD.bazel index 5686f7289667a..fbc2b61268d18 100644 --- a/dumpling/log/BUILD.bazel +++ b/dumpling/log/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "log", @@ -11,3 +11,12 @@ go_library( "@org_uber_go_zap//:zap", ], ) + +go_test( + name = "log_test", + timeout = "short", + srcs = ["log_test.go"], + embed = [":log"], + flaky = True, + deps = ["@com_github_stretchr_testify//require"], +) diff --git a/dumpling/log/log_test.go b/dumpling/log/log_test.go new file mode 100644 index 0000000000000..7713a32104fa5 --- /dev/null +++ b/dumpling/log/log_test.go @@ -0,0 +1,41 @@ +// Copyright 2025 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package log + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestInitLogNoPermission(t *testing.T) { + tmpDir := t.TempDir() + conf := &Config{ + Level: "debug", + File: tmpDir + "/test.log", + Format: "text", + } + + logger, _, err := InitAppLogger(conf) + require.NoError(t, err) + require.NotNil(t, logger) + + err = os.Chmod(tmpDir, 0) + require.NoError(t, err) + + _, _, err = InitAppLogger(conf) + require.ErrorContains(t, err, "permission denied") +} diff --git a/go.mod b/go.mod index 236e1bceb0d58..75435b48e8f39 100644 --- a/go.mod +++ b/go.mod @@ -89,7 +89,7 @@ require ( github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 github.com/pingcap/fn v1.0.0 github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d - github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a + github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84 github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e github.com/pingcap/tipb v0.0.0-20250331100511-d2c561dad347 @@ -336,4 +336,3 @@ replace ( sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 ) - diff --git a/go.sum b/go.sum index c588d7c643533..fa0301c0a6c6b 100644 --- a/go.sum +++ b/go.sum @@ -685,8 +685,8 @@ github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d h1:52qhTQG8G8V/pHo github.com/pingcap/kvproto v0.0.0-20250224053625-b6a98c6bf02d/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8= github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM= github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= -github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a h1:WIhmJBlNGmnCWH6TLMdZfNEDaiU8cFpZe3iaqDbQ0M8= -github.com/pingcap/log v1.1.1-0.20241212030209-7e3ff8601a2a/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA= +github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84 h1:ljnSbUq7LOkUtLtDXjTS5GanSWSAQ8pgVn7ucXMeMK8= +github.com/pingcap/log v1.1.1-0.20250424032633-85a82d016f84/go.mod h1:ORfBOFp1eteu2odzsyaxI+b8TzJwgjwyQcGhI+9SfEA= github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5 h1:T4pXRhBflzDeAhmOQHNPRRogMYxP13V7BkYw3ZsoSfE= github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5/go.mod h1:rlimy0GcTvjiJqvD5mXTRr8O2eNZPBrcUgiWVYp9530= github.com/pingcap/tipb v0.0.0-20250331100511-d2c561dad347 h1:PAeUQaG0EEugM2fVlMPYPzrJPOY5uvvi082VJKMadCQ=