Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <jfargher@gitlab.com>2022-03-21 23:00:32 +0300
committerJames Fargher <jfargher@gitlab.com>2022-03-31 01:27:17 +0300
commit084bc3049d8b6d308995cfb4c66efe0e310a6c4d (patch)
tree7dbadb7493ca783eb7b8c0595201664543e8705e
parent50b8de6bbf1da2f24896a8c7e2b7575e5ba644f8 (diff)
git2go: Set stderr to be the log ouput
-rw-r--r--internal/git2go/executor.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/internal/git2go/executor.go b/internal/git2go/executor.go
index 681024d28..b903eb217 100644
--- a/internal/git2go/executor.go
+++ b/internal/git2go/executor.go
@@ -16,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage"
+ glog "gitlab.com/gitlab-org/gitaly/v14/internal/log"
"gitlab.com/gitlab-org/gitaly/v14/internal/version"
)
@@ -29,9 +30,10 @@ var (
// Executor executes gitaly-git2go.
type Executor struct {
- binaryPath string
- gitCmdFactory git.CommandFactory
- locator storage.Locator
+ binaryPath string
+ gitCmdFactory git.CommandFactory
+ locator storage.Locator
+ logFormat, logLevel string
}
// NewExecutor returns a new gitaly-git2go executor using binaries as configured in the given
@@ -41,6 +43,8 @@ func NewExecutor(cfg config.Cfg, gitCmdFactory git.CommandFactory, locator stora
binaryPath: filepath.Join(cfg.BinDir, BinaryName),
gitCmdFactory: gitCmdFactory,
locator: locator,
+ logFormat: cfg.Logging.Format,
+ logLevel: cfg.Logging.Level,
}
}
@@ -52,8 +56,15 @@ func (b *Executor) run(ctx context.Context, repo repository.GitRepo, stdin io.Re
env := alternates.Env(repoPath, repo.GetGitObjectDirectory(), repo.GetGitAlternateObjectDirectories())
- var stderr, stdout bytes.Buffer
- cmd, err := command.New(ctx, exec.Command(b.binaryPath, args...), stdin, &stdout, &stderr, env...)
+ // Pass the log output directly to gitaly-git2go. No need to reinterpret
+ // these logs as long as the destination is an append-only file. See
+ // https://pkg.go.dev/github.com/sirupsen/logrus#readme-thread-safety
+ log := glog.Default().Logger.Out
+
+ args = append([]string{"-log-format", b.logFormat, "-log-level", b.logLevel}, args...)
+
+ var stdout bytes.Buffer
+ cmd, err := command.New(ctx, exec.Command(b.binaryPath, args...), stdin, &stdout, log, env...)
if err != nil {
return nil, err
}