summaryrefslogtreecommitdiff
path: root/internal/io/dlog/dlog.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-09-28 21:11:50 +0300
committerPaul Buetow <paul@buetow.org>2021-10-02 12:26:36 +0300
commit609921f9c783941eaa9019a92b78ec45b49d681c (patch)
treec4fc6b20404d0f922dc2825e4624be8c04479cbf /internal/io/dlog/dlog.go
parentfcaa94c7453efa0d74e330128c0f5c2cde8f11b3 (diff)
can have daily and normal file log rotation
Diffstat (limited to 'internal/io/dlog/dlog.go')
-rw-r--r--internal/io/dlog/dlog.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/io/dlog/dlog.go b/internal/io/dlog/dlog.go
index 49b405d..49533a5 100644
--- a/internal/io/dlog/dlog.go
+++ b/internal/io/dlog/dlog.go
@@ -36,19 +36,21 @@ func Start(ctx context.Context, wg *sync.WaitGroup, sourceProcess source, logLev
Common.FatalPanic("Logger already started")
}
+ strategy := loggers.GetStrategy(config.Common.LogStrategy)
level := newLevel(logLevel)
+
switch sourceProcess {
case CLIENT:
// This is a DTail client process running.
impl := loggers.FOUT
- Client = New(CLIENT, CLIENT, impl, level)
- Server = New(CLIENT, SERVER, impl, level)
+ Client = New(CLIENT, CLIENT, level, impl, strategy)
+ Server = New(CLIENT, SERVER, level, impl, strategy)
Common = Client
case SERVER:
// This is a DTail server process running.
impl := loggers.FILE
- Client = New(SERVER, CLIENT, impl, level)
- Server = New(SERVER, SERVER, impl, level)
+ Client = New(SERVER, CLIENT, level, impl, strategy)
+ Server = New(SERVER, SERVER, level, impl, strategy)
Common = Server
}
@@ -80,13 +82,13 @@ type DLog struct {
}
// New creates a new DTail logger.
-func New(sourceProcess, sourcePackage source, impl loggers.Impl, maxLevel level) *DLog {
+func New(sourceProcess, sourcePackage source, maxLevel level, impl loggers.Impl, strategy loggers.Strategy) *DLog {
hostname, err := os.Hostname()
if err != nil {
panic(err)
}
return &DLog{
- logger: loggers.Factory(sourceProcess.String(), impl),
+ logger: loggers.Factory(sourceProcess.String(), impl, strategy),
sourceProcess: sourceProcess,
sourcePackage: sourcePackage,
maxLevel: maxLevel,