Ejemplo n.º 1
0
func InitLog(configPath string) {
	logsink.UseFileConfig()
	wcg.ConfigureProcess(configPath)
	var logger = wcg.NewLogger(nil)
	if wcg.DefaultLogConfig.NumSinks() == 0 {
		wcg.DefaultLogConfig.AddSink(
			logsink.NewIOLogSink(
				"",
				os.Stderr,
				true,
			),
			wcg.DefaultLogConfig.Level,
		)
		logger.Warnf("No LogSink is specified, fail back to stderr")
	}
	// normalize path
	logger.Infof("Used configuration file: %q", configPath)
	logger.Infof("Target Endpoint: %q", DefaultConfig.Endpoint)
	logger.Debugf("Token: %q", DefaultConfig.Token)
}
Ejemplo n.º 2
0
func main() {
	app := cli.NewApp()
	app.Name = "speedland-ng-gphoto"
	app.Usage = "Google Photo Client for speedland-ng app"
	app.Version = version
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "config, c",
			Value:  "wcg.ini",
			Usage:  "configuration file",
			EnvVar: "WCG_INI_FILE",
		},
	}
	app.Before = func(c *cli.Context) error {
		logsink.UseFileConfig()
		wcg.ConfigureProcess(c.String("config"))
		if wcg.DefaultLogConfig.NumSinks() == 0 {
			wcg.DefaultLogConfig.AddSink(
				logsink.NewIOLogSink(
					"",
					os.Stderr,
					true,
				),
				wcg.DefaultLogConfig.Level,
			)
		}
		return nil
	}
	app.Commands = []cli.Command{
		commandLs,
		commandMkalbum,
		commandUpload,
		commandCopy,
		commandRm,
		commandDebug,
	}
	app.Run(os.Args)
}