diff --git a/config.example.yaml b/config.example.yaml index 5798adc..374bf3c 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -27,12 +27,20 @@ connection: logging: # log-level:[debug|info|error] Verbosity level for stdout and log file (default: info) log-level: debug - # log-database-level:[debug|info|error] Verbosity level for database storing (default: info) + # log-database-level:[debug|info|error|none] Verbosity level for database storing (default: info) log-database-level: debug # log-file: File name to store logs log-file: session.log # log-file-format:[json|text] Format of file logs (default: json) log-file-format: text + # log-file-rotate Rotate log files + log-file-rotate: true + # log-file-size: Maximum size in MB of the log file before it gets rotated (default: 100) + log-file-size: 10 + # log-file-age: Number of days to retain old log files, 0 means forever (default: 0) + log-file-age: 28 + # log-file-number: Maximum number of old log files to retain, 0 to retain all (default: 0) + log-file-number: 10 # - Bootstrap Settings - start: diff --git a/docs/README.rst b/docs/README.rst index b2bb75a..a3195b9 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -77,21 +77,24 @@ Command line options --log-file= File name to store logs --log-file-format=[json|text] Format of file logs (default: json) --log-file-rotate Rotate log files + --log-file-size= Maximum size in MB of the log file before it gets rotated (default: 100) + --log-file-age= Number of days to retain old log files, 0 means forever (default: 0) + --log-file-number= Maximum number of old log files to retain, 0 to retain all (default: 0) Start: -f, --file= SQL script file to execute during startup - --init Initialize database schema to the latest version and exit. - Can be used with --upgrade + --init Initialize database schema to the latest version and exit. Can be used + with --upgrade --upgrade Upgrade database to the latest version - --debug Run in debug mode. Only asynchronous chains will be executed + --debug Run in debug mode. Only asynchronous chains will be executed Resource: - --cron-workers= Number of parallel workers for scheduled chains (default: 16) - --interval-workers= Number of parallel workers for interval chains (default: 16) - --chain-timeout= Abort any chain that takes more than the specified number of + --cron-workers= Number of parallel workers for scheduled chains (default: 16) + --interval-workers= Number of parallel workers for interval chains (default: 16) + --chain-timeout= Abort any chain that takes more than the specified number of milliseconds - --task-timeout= Abort any task within a chain that takes more than the specified - number of milliseconds + --task-timeout= Abort any task within a chain that takes more than the specified number + of milliseconds REST: --rest-port= REST API port (default: 0) [$PGTT_RESTPORT] diff --git a/internal/config/cmdparser.go b/internal/config/cmdparser.go index f0e3de2..29af520 100644 --- a/internal/config/cmdparser.go +++ b/internal/config/cmdparser.go @@ -26,6 +26,9 @@ type LoggingOpts struct { LogFile string `long:"log-file" mapstructure:"log-file" description:"File name to store logs"` LogFileFormat string `long:"log-file-format" mapstructure:"log-file-format" description:"Format of file logs" choice:"json" choice:"text" default:"json"` LogFileRotate bool `long:"log-file-rotate" mapstructure:"log-file-rotate" description:"Rotate log files"` + LogFileSize int `long:"log-file-size" mapstructure:"log-file-size" description:"Maximum size in MB of the log file before it gets rotated" default:"100"` + LogFileAge int `long:"log-file-age" mapstructure:"log-file-age" description:"Number of days to retain old log files, 0 means forever" default:"0"` + LogFileNumber int `long:"log-file-number" mapstructure:"log-file-number" description:"Maximum number of old log files to retain, 0 to retain all" default:"0"` } // StartOpts specifies the application startup options diff --git a/internal/log/log.go b/internal/log/log.go index 68f844f..3c88055 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -27,9 +27,9 @@ func getLogFileWriter(opts config.LoggingOpts) any { if opts.LogFileRotate { return &lumberjack.Logger{ Filename: opts.LogFile, - MaxSize: 10, // megabytes after which new file is created - MaxBackups: 10, // number of backups - MaxAge: 7, //days + MaxSize: opts.LogFileSize, + MaxBackups: opts.LogFileNumber, + MaxAge: opts.LogFileAge, } } return opts.LogFile