Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Allow logging to be configured by logfile #4123

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions cmd/armada-load-tester/cmd/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strings"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"

log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/pkg/client"
"github.com/armadaproject/armada/pkg/client/domain"
"github.com/armadaproject/armada/pkg/client/util"
Expand Down Expand Up @@ -72,7 +72,7 @@ var loadtestCmd = &cobra.Command{
loadTestSpec := &domain.LoadTestSpecification{}
err := util.BindJsonOrYaml(filePath, loadTestSpec)
if err != nil {
log.Error(err)
log.Error(err.Error())
os.Exit(1)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/armada-load-tester/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package cmd
import (
"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/pkg/client"
)

Expand All @@ -28,7 +28,7 @@ The location of this file can be passed in using --config argument or picked fro
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
log.Error(err)
log.Error(err.Error())
os.Exit(1)
}
}
Expand All @@ -37,7 +37,7 @@ var cfgFile string

func initConfig() {
if err := client.LoadCommandlineArgsFromConfigFile(cfgFile); err != nil {
log.Error(err)
log.Error(err.Error())
os.Exit(1)
}
}
4 changes: 2 additions & 2 deletions cmd/binoculars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"syscall"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"google.golang.org/grpc"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/armadaproject/armada/internal/common/armadacontext"
gateway "github.com/armadaproject/armada/internal/common/grpc"
"github.com/armadaproject/armada/internal/common/health"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/common/profiling"
api "github.com/armadaproject/armada/pkg/api/binoculars"
)
Expand All @@ -35,7 +35,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.BinocularsConfig
Expand Down
3 changes: 2 additions & 1 deletion cmd/eventingester/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/eventingester"

"github.com/spf13/pflag"
Expand All @@ -24,7 +25,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
logging.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.EventIngesterConfiguration
Expand Down
6 changes: 3 additions & 3 deletions cmd/executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"syscall"

"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/armadacontext"
"github.com/armadaproject/armada/internal/common/health"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/common/profiling"
"github.com/armadaproject/armada/internal/executor"
"github.com/armadaproject/armada/internal/executor/configuration"
Expand All @@ -31,7 +31,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.ExecutorConfiguration
Expand Down Expand Up @@ -61,7 +61,7 @@ func main() {
)
defer shutdownMetricServer()

shutdown, wg := executor.StartUp(armadacontext.Background(), log.NewEntry(log.StandardLogger()), config)
shutdown, wg := executor.StartUp(armadacontext.Background(), config)
go func() {
<-shutdownChannel
shutdown()
Expand Down
6 changes: 3 additions & 3 deletions cmd/fakeexecutor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"os/signal"
"syscall"

log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/armadacontext"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/common/profiling"
"github.com/armadaproject/armada/internal/executor/configuration"
"github.com/armadaproject/armada/internal/executor/fake"
Expand All @@ -29,7 +29,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.ExecutorConfiguration
Expand All @@ -54,7 +54,7 @@ func main() {
shutdownMetricServer := common.ServeMetrics(config.Metric.Port)
defer shutdownMetricServer()

shutdown, wg := fake.StartUp(config, nodes)
shutdown, wg := fake.StartUp(armadacontext.Background(), config, nodes)
go func() {
<-shutdownChannel
shutdown()
Expand Down
4 changes: 2 additions & 2 deletions cmd/lookoutingesterv2/dbloadtester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"sigs.k8s.io/yaml"

"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/app"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/lookoutingesterv2/configuration"
"github.com/armadaproject/armada/internal/lookoutingesterv2/dbloadtester"
)
Expand Down Expand Up @@ -45,7 +45,7 @@ const ReportTemplate string = `
`

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.LookoutIngesterV2Configuration
Expand Down
4 changes: 2 additions & 2 deletions cmd/lookoutingesterv2/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/armadaproject/armada/internal/common"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/lookoutingesterv2"
"github.com/armadaproject/armada/internal/lookoutingesterv2/benchmark"
"github.com/armadaproject/armada/internal/lookoutingesterv2/configuration"
Expand All @@ -27,7 +27,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.LookoutIngesterV2Configuration
Expand Down
6 changes: 3 additions & 3 deletions cmd/lookoutv2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"os/signal"
"syscall"

log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/utils/clock"

"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/armadacontext"
"github.com/armadaproject/armada/internal/common/database"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/common/profiling"
"github.com/armadaproject/armada/internal/lookoutv2"
"github.com/armadaproject/armada/internal/lookoutv2/configuration"
Expand Down Expand Up @@ -117,7 +117,7 @@ func prune(ctx *armadacontext.Context, config configuration.LookoutV2Config) {
}

func main() {
common.ConfigureLogging()
log.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config configuration.LookoutV2Config
Expand Down Expand Up @@ -148,7 +148,7 @@ func main() {
restapi.UIConfig = config.UIConfig

if err := lookoutv2.Serve(config); err != nil {
log.Error(err)
log.Error(err.Error())
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion cmd/scheduler/cmd/migrate_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"time"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/armadaproject/armada/internal/common/armadacontext"
"github.com/armadaproject/armada/internal/common/database"
log "github.com/armadaproject/armada/internal/common/logging"
schedulerdb "github.com/armadaproject/armada/internal/scheduler/database"
)

Expand Down
3 changes: 2 additions & 1 deletion cmd/scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (

"github.com/armadaproject/armada/cmd/scheduler/cmd"
"github.com/armadaproject/armada/internal/common"
"github.com/armadaproject/armada/internal/common/logging"
)

func main() {
common.ConfigureLogging()
logging.MustConfigureApplicationLogging()
common.BindCommandlineArguments()
if err := cmd.RootCmd().Execute(); err != nil {
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/scheduleringester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"os"

"github.com/armadaproject/armada/internal/common/logging"

"github.com/spf13/pflag"
"github.com/spf13/viper"

Expand All @@ -24,7 +26,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
logging.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

var config scheduleringester.Configuration
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"syscall"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"

Expand All @@ -17,6 +16,7 @@ import (
gateway "github.com/armadaproject/armada/internal/common/grpc"
"github.com/armadaproject/armada/internal/common/health"
"github.com/armadaproject/armada/internal/common/logging"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/common/profiling"
"github.com/armadaproject/armada/internal/server"
"github.com/armadaproject/armada/internal/server/configuration"
Expand All @@ -35,7 +35,7 @@ func init() {
}

func main() {
common.ConfigureLogging()
logging.MustConfigureApplicationLogging()
common.BindCommandlineArguments()

// TODO Load relevant config in one place: don't use viper here and in LoadConfig.
Expand Down Expand Up @@ -117,6 +117,6 @@ func main() {
}()

if err := g.Wait(); err != nil {
logging.WithStacktrace(log.NewEntry(log.StandardLogger()), err).Error("Armada server shut down")
logging.WithStacktrace(err).Error("Armada server shut down")
}
}
9 changes: 4 additions & 5 deletions cmd/simulator/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"runtime/pprof"
"time"

"github.com/armadaproject/armada/internal/scheduler/simulator/sink"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/armadaproject/armada/internal/common/armadacontext"
log "github.com/armadaproject/armada/internal/common/logging"
"github.com/armadaproject/armada/internal/scheduler/simulator"
"github.com/armadaproject/armada/internal/scheduler/simulator/sink"
"github.com/armadaproject/armada/internal/scheduler/testfixtures"
)

Expand Down Expand Up @@ -139,11 +138,11 @@ func runSimulations(cmd *cobra.Command, args []string) error {
log.Infof("Will write profiling information to %s", profilingFile)
f, err := os.Create(profilingFile)
if err != nil {
log.Fatal(err)
log.Fatal(err.Error())
}
err = pprof.StartCPUProfile(f)
if err != nil {
log.Fatal(err)
log.Fatal(err.Error())
}
defer pprof.StopCPUProfile()
}
Expand Down
13 changes: 13 additions & 0 deletions config/logging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
console:
level: INFO
format: text
file:
enabled: true
level: INFO
format: json
logfile: app.log
rotation:
maxSizeMb: 5
maxBackups: 3
maxAgeDays: 7
compress: false
Loading
Loading