Merge branch 'dev' into vod

This commit is contained in:
Ingo Oppermann 2023-05-03 10:34:37 +02:00
commit d97a2709d8
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
2 changed files with 20 additions and 12 deletions

View File

@ -15,11 +15,11 @@ init:
## build: Build core (default)
build:
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core${BINSUFFIX}
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core${BINSUFFIX} -trimpath
# github workflow workaround
build_linux:
CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core
CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core -trimpath
## swagger: Update swagger API documentation (requires github.com/swaggo/swag)
swagger:
@ -69,19 +69,19 @@ lint:
## import: Build import binary
import:
cd app/import && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../import -ldflags="-s -w"
cd app/import && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../import -trimpath -ldflags="-s -w"
# github workflow workaround
import_linux:
cd app/import && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../import -ldflags="-s -w"
cd app/import && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../import -trimpath -ldflags="-s -w"
## ffmigrate: Build ffmpeg migration binary
ffmigrate:
cd app/ffmigrate && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../ffmigrate -ldflags="-s -w"
cd app/ffmigrate && CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ../../ffmigrate -trimpath -ldflags="-s -w"
# github workflow workaround
ffmigrate_linux:
cd app/ffmigrate && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../ffmigrate -ldflags="-s -w"
cd app/ffmigrate && CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o ../../ffmigrate -trimpath -ldflags="-s -w"
## coverage: Generate code coverage analysis
coverage:
@ -94,11 +94,11 @@ commit: vet fmt lint test build
## release: Build a release binary of core
release:
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)"
CGO_ENABLED=${CGO_ENABLED} GOOS=${GOOS} GOARCH=${GOARCH} go build -o core -trimpath -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)"
# github workflow workaround
release_linux:
CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)"
CGO_ENABLED=0 GOOS=linux GOARCH=${OSARCH} go build -o core -trimpath -ldflags="-s -w -X github.com/datarhei/core/v16/app.Commit=$(COMMIT) -X github.com/datarhei/core/v16/app.Branch=$(BRANCH) -X github.com/datarhei/core/v16/app.Build=$(BUILD)"
## docker: Build standard Docker image
docker:

View File

@ -6,6 +6,7 @@ import (
"fmt"
"reflect"
"runtime"
"runtime/debug"
"strings"
"time"
)
@ -103,8 +104,9 @@ type Logger interface {
// logger is an implementation of the Logger interface.
type logger struct {
output Writer
component string
output Writer
component string
modulePath string
}
// New returns an implementation of the Logger interface.
@ -113,6 +115,10 @@ func New(component string) Logger {
component: component,
}
if info, ok := debug.ReadBuildInfo(); ok {
l.modulePath = info.Path
}
return l
}
@ -122,8 +128,9 @@ func (l *logger) Close() {
func (l *logger) clone() *logger {
clone := &logger{
output: l.output,
component: l.component,
output: l.output,
component: l.component,
modulePath: l.modulePath,
}
return clone
@ -223,6 +230,7 @@ func (e *Event) WithComponent(component string) Logger {
func (e *Event) Log(format string, args ...interface{}) {
_, file, line, _ := runtime.Caller(1)
file = strings.TrimPrefix(file, e.logger.modulePath)
n := e.clone()