mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-18 04:40:03 +02:00
internal/config: adding --log-file-timestamp flag.
This commit is contained in:
parent
aa43fc003f
commit
aaf490456c
3 changed files with 19 additions and 12 deletions
|
|
@ -37,8 +37,9 @@ func NewBuilder() *Builder {
|
||||||
"telegram.channel": "telegram-channel",
|
"telegram.channel": "telegram-channel",
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
"log.maxfilesize": "log-max-filesize",
|
"log.maxfilesize": "log-max-filesize",
|
||||||
"log.maxtime": "log-max-time",
|
"log.maxtime": "log-max-time",
|
||||||
|
"log.file_timestamp_format": "log-file-timestamp",
|
||||||
|
|
||||||
// Ship
|
// Ship
|
||||||
"ship.url": "ship-url",
|
"ship.url": "ship-url",
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,11 @@ func TestBuilder(t *testing.T) {
|
||||||
Api: "http://127.0.0.1:8080",
|
Api: "http://127.0.0.1:8080",
|
||||||
MessageCodec: "mojibake",
|
MessageCodec: "mojibake",
|
||||||
Log: log.Config{
|
Log: log.Config{
|
||||||
Filename: "some_file.log",
|
Filename: "some_file.log",
|
||||||
Directory: "/path/to/whatever",
|
Directory: "/path/to/whatever",
|
||||||
MaxFileSize: 200,
|
MaxFileSize: 200,
|
||||||
MaxTime: 30 * time.Minute,
|
MaxTime: 30 * time.Minute,
|
||||||
|
FileTimestampFormat: "20060102@150405",
|
||||||
},
|
},
|
||||||
Ship: ShipConfig{
|
Ship: ShipConfig{
|
||||||
Url: "127.0.0.1:8089",
|
Url: "127.0.0.1:8089",
|
||||||
|
|
@ -50,6 +51,7 @@ log:
|
||||||
directory: /path/to/whatever
|
directory: /path/to/whatever
|
||||||
maxtime: 30m
|
maxtime: 30m
|
||||||
maxfilesize: 200b
|
maxfilesize: 200b
|
||||||
|
file_timestamp_format: 20060102@150405
|
||||||
ship:
|
ship:
|
||||||
url: "127.0.0.1:8089"
|
url: "127.0.0.1:8089"
|
||||||
irreversible_only: true
|
irreversible_only: true
|
||||||
|
|
@ -79,10 +81,11 @@ func TestBuilder_ConfigWithFlags(t *testing.T) {
|
||||||
Api: "https://api.example.com",
|
Api: "https://api.example.com",
|
||||||
MessageCodec: "msgpack",
|
MessageCodec: "msgpack",
|
||||||
Log: log.Config{
|
Log: log.Config{
|
||||||
Filename: "mylog.log",
|
Filename: "mylog.log",
|
||||||
Directory: "/var/log",
|
Directory: "/var/log",
|
||||||
MaxFileSize: 200,
|
MaxFileSize: 200,
|
||||||
MaxTime: 30 * time.Minute,
|
MaxTime: 30 * time.Minute,
|
||||||
|
FileTimestampFormat: "2006-01-02_150405",
|
||||||
},
|
},
|
||||||
Ship: ShipConfig{
|
Ship: ShipConfig{
|
||||||
Url: "127.0.0.1:8089",
|
Url: "127.0.0.1:8089",
|
||||||
|
|
@ -165,6 +168,7 @@ func TestBuilder_Flags(t *testing.T) {
|
||||||
require.NoError(t, flags.Set("telegram-channel", "-293492332"))
|
require.NoError(t, flags.Set("telegram-channel", "-293492332"))
|
||||||
require.NoError(t, flags.Set("log-max-filesize", "25mb"))
|
require.NoError(t, flags.Set("log-max-filesize", "25mb"))
|
||||||
require.NoError(t, flags.Set("log-max-time", "10m"))
|
require.NoError(t, flags.Set("log-max-time", "10m"))
|
||||||
|
require.NoError(t, flags.Set("log-file-timestamp", "0102-15:04:05"))
|
||||||
require.NoError(t, flags.Set("ship-url", "ws://myship.com:7823"))
|
require.NoError(t, flags.Set("ship-url", "ws://myship.com:7823"))
|
||||||
require.NoError(t, flags.Set("start-block", "7327833"))
|
require.NoError(t, flags.Set("start-block", "7327833"))
|
||||||
require.NoError(t, flags.Set("end-block", "329408392"))
|
require.NoError(t, flags.Set("end-block", "329408392"))
|
||||||
|
|
@ -181,8 +185,9 @@ func TestBuilder_Flags(t *testing.T) {
|
||||||
Api: "https://myapi",
|
Api: "https://myapi",
|
||||||
MessageCodec: "binary",
|
MessageCodec: "binary",
|
||||||
Log: log.Config{
|
Log: log.Config{
|
||||||
MaxFileSize: 25 * 1000 * 1000, // 25 mb
|
MaxFileSize: 25 * 1000 * 1000, // 25 mb
|
||||||
MaxTime: time.Minute * 10,
|
MaxTime: time.Minute * 10,
|
||||||
|
FileTimestampFormat: "0102-15:04:05",
|
||||||
},
|
},
|
||||||
Ship: ShipConfig{
|
Ship: ShipConfig{
|
||||||
Url: "ws://myship.com:7823",
|
Url: "ws://myship.com:7823",
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func GetFlags() *pflag.FlagSet {
|
||||||
flags.StringP("log", "l", "", "Path to log file (default: print to stdout/stderr)")
|
flags.StringP("log", "l", "", "Path to log file (default: print to stdout/stderr)")
|
||||||
flags.String("log-max-filesize", "10mb", "Max filesize for logfile to rotate")
|
flags.String("log-max-filesize", "10mb", "Max filesize for logfile to rotate")
|
||||||
flags.Duration("log-max-time", time.Hour*24, "Max time for logfile to rotate")
|
flags.Duration("log-max-time", time.Hour*24, "Max time for logfile to rotate")
|
||||||
|
flags.String("log-file-timestamp", "2006-01-02_150405", "Timestamp format to use when rotating log files")
|
||||||
|
|
||||||
// Ship
|
// Ship
|
||||||
flags.String("ship-url", "ws://127.0.0.1:8080", "Url to ship node")
|
flags.String("ship-url", "ws://127.0.0.1:8080", "Url to ship node")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue