mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-08 16:45:30 +00:00
parent
8f44ca3f3d
commit
db057b8d82
3 changed files with 7 additions and 2 deletions
|
@ -15,8 +15,10 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/6543/logfile-open"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -55,14 +57,14 @@ func SetupGlobalLogger(c *cli.Context) {
|
|||
noColor := c.Bool("nocolor")
|
||||
logFile := c.String("log-file")
|
||||
|
||||
var file *os.File
|
||||
var file io.ReadWriteCloser
|
||||
switch logFile {
|
||||
case "", "stderr": // default case
|
||||
file = os.Stderr
|
||||
case "stdout":
|
||||
file = os.Stdout
|
||||
default: // a file was set
|
||||
openFile, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o660)
|
||||
openFile, err := logfile.OpenFileWithContext(c.Context, logFile, 0o660)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msgf("could not open log file '%s'", logFile)
|
||||
}
|
||||
|
|
1
go.mod
1
go.mod
|
@ -6,6 +6,7 @@ require (
|
|||
code.gitea.io/sdk/gitea v0.15.1-0.20221016183512-2d9ee57af1e0
|
||||
codeberg.org/6543/go-yaml2json v1.0.0
|
||||
codeberg.org/6543/xyaml v1.1.0
|
||||
github.com/6543/logfile-open v1.1.1
|
||||
github.com/alessio/shellescape v1.4.1
|
||||
github.com/antonmedv/expr v1.12.5
|
||||
github.com/bmatcuk/doublestar/v4 v4.6.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -10,6 +10,8 @@ gitea.com/6543/xorm v1.3.3-0.20230807141308-fc77a3b490a8/go.mod h1:qFJGFoVYbbIdn
|
|||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
|
||||
github.com/6543/logfile-open v1.1.1 h1:OKBz2GwxGaJRAOZehsSAl9antvHDG3yq83cpQcQ26aw=
|
||||
github.com/6543/logfile-open v1.1.1/go.mod h1:ZoEy7pW2mexmQxiZIqPCeh8vUxVuiHYXmSZNbvEb51g=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
|
||||
|
|
Loading…
Reference in a new issue