Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/execd-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ jobs:
python3 tests/smoke_api.py
- name: Show logs
if: always()
run: cat components/execd/execd.log
run: |
set -x
cat components/execd/startup.log || true
cat components/execd/execd.log || true
2 changes: 2 additions & 0 deletions components/execd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ logs.Error("message") // error
logs.Debug("message") // debug
```

- Env: `EXECD_LOG_FILE` writes execd logs to the given file path; when unset, logs are sent to stdout.

Log levels (0-7):

- 0: Emergency
Expand Down
2 changes: 2 additions & 0 deletions components/execd/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ logs.Error("message") // 错误条件
logs.Debug("message") // 调试级别消息
```

- 环境变量:`EXECD_LOG_FILE` 指定日志输出文件;未设置时日志输出到标准输出(stdout)。

日志级别(0-7):

- 0:紧急
Expand Down
14 changes: 14 additions & 0 deletions components/execd/pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ package log

import (
"fmt"
"os"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

const logFileEnvKey = "EXECD_LOG_FILE"

var (
atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel)
base *zap.Logger
Expand All @@ -30,6 +33,17 @@ var (
func init() {
cfg := zap.NewProductionConfig()
cfg.Level = atomicLevel

logFile := os.Getenv(logFileEnvKey)
if logFile != "" {
cfg.OutputPaths = []string{logFile}
cfg.ErrorOutputPaths = []string{logFile}
} else {
// outputs log to stdout pipe by default
cfg.OutputPaths = []string{"stdout"}
cfg.ErrorOutputPaths = []string{"stdout"}
}

logger, err := cfg.Build()
if err != nil {
panic(fmt.Sprintf("failed to init logger: %v", err))
Expand Down
3 changes: 2 additions & 1 deletion components/execd/tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ source tests/jupyter.sh
install_jupyter

export EXECD_API_GRACE_SHUTDOWN=500ms
./bin/execd -jupyter-host=http://127.0.0.1:${JUPYTER_PORT} --jupyter-token=${JUPYTER_TOKEN} --log-level=7 >execd.log 2>&1 &
export EXECD_LOG_FILE=execd.log
./bin/execd -jupyter-host=http://127.0.0.1:${JUPYTER_PORT} --jupyter-token=${JUPYTER_TOKEN} --log-level=7 >startup.log 2>&1 &
Loading