Improve logging (#1171)
* feat: use logger from context wherever possible Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add step/job id and results to json logs Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * test: value to be masked should not be hard-coded in the action Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * fix: replace values following ::add-mask:: in evaluated strings Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: [DEBUG] identifier for debug logs to distinguish them Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: replace logger with step logger The container gets injected a job logger, but during the time that steps are run, we want to use the step logger. This commit wraps pre/main/post steps in an executor that replaces the job logger with a step logger. Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add pre/post stage identifier fields to json log output Co-authored-by: Markus Wolf <markus.wolf@new-work.se> * feat: add job/step result status to skipped steps/jobs Co-authored-by: Markus Wolf <markus.wolf@new-work.se> Co-authored-by: Markus Wolf <markus.wolf@new-work.se> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/nektos/act/pkg/common"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type FileContainerResourceURL struct {
|
||||
@@ -241,6 +240,7 @@ func downloads(router *httprouter.Router, fsys fs.FS) {
|
||||
|
||||
func Serve(ctx context.Context, artifactPath string, port string) context.CancelFunc {
|
||||
serverContext, cancel := context.WithCancel(ctx)
|
||||
logger := common.Logger(serverContext)
|
||||
|
||||
if artifactPath == "" {
|
||||
return cancel
|
||||
@@ -248,7 +248,7 @@ func Serve(ctx context.Context, artifactPath string, port string) context.Cancel
|
||||
|
||||
router := httprouter.New()
|
||||
|
||||
log.Debugf("Artifacts base path '%s'", artifactPath)
|
||||
logger.Debugf("Artifacts base path '%s'", artifactPath)
|
||||
fs := os.DirFS(artifactPath)
|
||||
uploads(router, MkdirFsImpl{artifactPath, fs})
|
||||
downloads(router, fs)
|
||||
@@ -258,9 +258,9 @@ func Serve(ctx context.Context, artifactPath string, port string) context.Cancel
|
||||
|
||||
// run server
|
||||
go func() {
|
||||
log.Infof("Start server on http://%s:%s", ip, port)
|
||||
logger.Infof("Start server on http://%s:%s", ip, port)
|
||||
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -269,7 +269,7 @@ func Serve(ctx context.Context, artifactPath string, port string) context.Cancel
|
||||
<-serverContext.Done()
|
||||
|
||||
if err := server.Shutdown(ctx); err != nil {
|
||||
log.Errorf("Failed shutdown gracefully - force shutdown: %v", err)
|
||||
logger.Errorf("Failed shutdown gracefully - force shutdown: %v", err)
|
||||
server.Close()
|
||||
}
|
||||
}()
|
||||
|
Reference in New Issue
Block a user