mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 17:33:09 -06:00
Remove LOG_DIR and use the configuration instead
Signed-off-by: Tristan Claverie <public@tclaverie.eu>
This commit is contained in:
parent
ae4992fa83
commit
c26d23b89f
|
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
||||||
|
|
@ -37,12 +36,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logDir = os.Getenv("LOG_DIR")
|
|
||||||
configPath = flag.String("config", "dendrite.yaml", "The path to the config file, For more information see the config file in this repository")
|
configPath = flag.String("config", "dendrite.yaml", "The path to the config file, For more information see the config file in this repository")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(logDir)
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -51,6 +49,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteClientAPI")
|
closer, err := cfg.SetupTracing("DendriteClientAPI")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
||||||
|
|
@ -33,12 +32,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logDir = os.Getenv("LOG_DIR")
|
|
||||||
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(logDir)
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -50,6 +48,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteFederationAPI")
|
closer, err := cfg.SetupTracing("DendriteFederationAPI")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
|
@ -35,7 +34,7 @@ import (
|
||||||
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(os.Getenv("LOG_DIR"))
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -47,6 +46,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteFederationSender")
|
closer, err := cfg.SetupTracing("DendriteFederationSender")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
||||||
|
|
@ -31,12 +30,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logDir = os.Getenv("LOG_DIR")
|
|
||||||
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(logDir)
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -48,6 +46,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteMediaAPI")
|
closer, err := cfg.SetupTracing("DendriteMediaAPI")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
||||||
|
|
@ -63,7 +62,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logDir = os.Getenv("LOG_DIR")
|
|
||||||
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
httpBindAddr = flag.String("http-bind-address", ":8008", "The HTTP listening port for the server")
|
httpBindAddr = flag.String("http-bind-address", ":8008", "The HTTP listening port for the server")
|
||||||
httpsBindAddr = flag.String("https-bind-address", ":8448", "The HTTPS listening port for the server")
|
httpsBindAddr = flag.String("https-bind-address", ":8448", "The HTTPS listening port for the server")
|
||||||
|
|
@ -72,7 +70,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(logDir)
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -84,6 +82,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteMonolith")
|
closer, err := cfg.SetupTracing("DendriteMonolith")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
||||||
|
|
@ -35,7 +34,7 @@ import (
|
||||||
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(os.Getenv("LOG_DIR"))
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -47,6 +46,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendritePublicRoomsAPI")
|
closer, err := cfg.SetupTracing("DendritePublicRoomsAPI")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/common/config"
|
"github.com/matrix-org/dendrite/common/config"
|
||||||
|
|
@ -32,12 +31,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logDir = os.Getenv("LOG_DIR")
|
|
||||||
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(logDir)
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -49,6 +47,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteRoomServer")
|
closer, err := cfg.SetupTracing("DendriteRoomServer")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
||||||
|
|
@ -39,7 +38,7 @@ import (
|
||||||
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
var configPath = flag.String("config", "dendrite.yaml", "The path to the config file. For more information, see the config file in this repository.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
common.SetupLogging(os.Getenv("LOG_DIR"))
|
common.SetupStdLogging()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -51,6 +50,8 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.SetupFileLogging(string(cfg.Logging.FPath), cfg.Derived.LogLevel)
|
||||||
|
|
||||||
closer, err := cfg.SetupTracing("DendriteSyncAPI")
|
closer, err := cfg.SetupTracing("DendriteSyncAPI")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatalf("Failed to start tracer")
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path"
|
||||||
|
|
||||||
"github.com/matrix-org/dugong"
|
"github.com/matrix-org/dugong"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
@ -31,8 +31,8 @@ func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
||||||
return f.Formatter.Format(entry)
|
return f.Formatter.Format(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupLogging configures the logging format and destination(s).
|
// SetupStdLogging configures the logging format to standard output. Typically, it is called when the config is not yet loaded.
|
||||||
func SetupLogging(logDir string) {
|
func SetupStdLogging() {
|
||||||
logrus.SetFormatter(&utcFormatter{
|
logrus.SetFormatter(&utcFormatter{
|
||||||
&logrus.TextFormatter{
|
&logrus.TextFormatter{
|
||||||
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
||||||
|
|
@ -42,12 +42,15 @@ func SetupLogging(logDir string) {
|
||||||
DisableSorting: false,
|
DisableSorting: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if logDir != "" {
|
}
|
||||||
_ = os.Mkdir(logDir, os.ModePerm)
|
|
||||||
|
// SetupFileLogging configures the logging format to a file.
|
||||||
|
func SetupFileLogging(logFile string, logLevel logrus.Level) {
|
||||||
|
logrus.SetLevel(logLevel)
|
||||||
|
if logFile != "" {
|
||||||
|
_ = os.MkdirAll(path.Dir(logFile), os.ModePerm)
|
||||||
logrus.AddHook(dugong.NewFSHook(
|
logrus.AddHook(dugong.NewFSHook(
|
||||||
filepath.Join(logDir, "info.log"),
|
logFile,
|
||||||
filepath.Join(logDir, "warn.log"),
|
|
||||||
filepath.Join(logDir, "error.log"),
|
|
||||||
&utcFormatter{
|
&utcFormatter{
|
||||||
&logrus.TextFormatter{
|
&logrus.TextFormatter{
|
||||||
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue