|
|
@ -17,7 +17,7 @@ |
|
|
|
package main |
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"runtime" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/minio/cli" |
|
|
|
"github.com/minio/cli" |
|
|
|
"github.com/minio/minio-xl/pkg/probe" |
|
|
|
"github.com/minio/minio-xl/pkg/probe" |
|
|
@ -32,42 +32,31 @@ var configLoggerCmd = cli.Command{ |
|
|
|
minio config {{.Name}} - {{.Usage}} |
|
|
|
minio config {{.Name}} - {{.Usage}} |
|
|
|
|
|
|
|
|
|
|
|
USAGE: |
|
|
|
USAGE: |
|
|
|
minio config {{.Name}} |
|
|
|
minio config {{.Name}} OPERATION [ARGS...] |
|
|
|
|
|
|
|
|
|
|
|
`, |
|
|
|
OPERATION = add | list | remove |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Inherit at one place
|
|
|
|
EXAMPLES: |
|
|
|
type config struct { |
|
|
|
1. Configure new mongo logger. |
|
|
|
*configV2 |
|
|
|
$ minio config {{.Name}} add mongo localhost:28710 mydb mylogger |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *config) IsFileLoggingEnabled() bool { |
|
|
|
2. Configure new syslog logger. NOTE: syslog logger is not supported on windows. |
|
|
|
if c.FileLogger.Filename != "" { |
|
|
|
$ minio config {{.Name}} add syslog localhost:554 udp |
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *config) IsSysloggingEnabled() bool { |
|
|
|
3. Configure new file logger. "/var/log" should be writable by user. |
|
|
|
if c.SyslogLogger.Network != "" && c.SyslogLogger.Addr != "" { |
|
|
|
$ minio config {{.Name}} add file /var/log/minio.log |
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *config) IsMongoLoggingEnabled() bool { |
|
|
|
4. List currently configured logger. |
|
|
|
if c.MongoLogger.Addr != "" && c.MongoLogger.DB != "" && c.MongoLogger.Collection != "" { |
|
|
|
$ minio config {{.Name}} list |
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
5. Remove/Reset a configured logger. |
|
|
|
return false |
|
|
|
$ minio config {{.Name}} remove mongo |
|
|
|
|
|
|
|
`, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *config) String() string { |
|
|
|
// Inherit at one place
|
|
|
|
str := fmt.Sprintf("Mongo -> Addr: %s, DB: %s, Collection: %s\n", c.MongoLogger.Addr, c.MongoLogger.DB, c.MongoLogger.Collection) |
|
|
|
type config struct { |
|
|
|
str = str + fmt.Sprintf("Syslog -> Addr: %s, Network: %s\n", c.SyslogLogger.Addr, c.SyslogLogger.Network) |
|
|
|
*configV2 |
|
|
|
str = str + fmt.Sprintf("File -> Filename: %s", c.FileLogger.Filename) |
|
|
|
|
|
|
|
return str |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func mainConfigLogger(ctx *cli.Context) { |
|
|
|
func mainConfigLogger(ctx *cli.Context) { |
|
|
@ -83,6 +72,9 @@ func mainConfigLogger(ctx *cli.Context) { |
|
|
|
enableLog2Mongo(&config{conf}, args.Tail()) |
|
|
|
enableLog2Mongo(&config{conf}, args.Tail()) |
|
|
|
} |
|
|
|
} |
|
|
|
if args.Get(0) == "syslog" { |
|
|
|
if args.Get(0) == "syslog" { |
|
|
|
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Syslog is not supported on windows.", nil) |
|
|
|
|
|
|
|
} |
|
|
|
enableLog2Syslog(&config{conf}, args.Tail()) |
|
|
|
enableLog2Syslog(&config{conf}, args.Tail()) |
|
|
|
} |
|
|
|
} |
|
|
|
if args.Get(0) == "file" { |
|
|
|
if args.Get(0) == "file" { |
|
|
@ -99,6 +91,9 @@ func mainConfigLogger(ctx *cli.Context) { |
|
|
|
fatalIf(err.Trace(), "Unable to save config.", nil) |
|
|
|
fatalIf(err.Trace(), "Unable to save config.", nil) |
|
|
|
} |
|
|
|
} |
|
|
|
if args.Get(0) == "syslog" { |
|
|
|
if args.Get(0) == "syslog" { |
|
|
|
|
|
|
|
if runtime.GOOS == "windows" { |
|
|
|
|
|
|
|
fatalIf(probe.NewError(errInvalidArgument), "Syslog is not supported on windows.", nil) |
|
|
|
|
|
|
|
} |
|
|
|
conf.SyslogLogger.Network = "" |
|
|
|
conf.SyslogLogger.Network = "" |
|
|
|
conf.SyslogLogger.Addr = "" |
|
|
|
conf.SyslogLogger.Addr = "" |
|
|
|
err := saveConfig(conf) |
|
|
|
err := saveConfig(conf) |
|
|
@ -111,7 +106,11 @@ func mainConfigLogger(ctx *cli.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ctx.Args().Get(0) == "list" { |
|
|
|
if ctx.Args().Get(0) == "list" { |
|
|
|
Println(&config{conf}) |
|
|
|
if globalJSONFlag { |
|
|
|
|
|
|
|
Println(conf.JSON()) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Println(conf) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|