shared/logging/log.go
func GetLogger(syslog string, logfile string, verbose bool, debug bool, customHandler log.Handler) (logger.Logger, error) {
	Log := log.New()

	var handlers []log.Handler
	var syshandler log.Handler

	// System specific handler
	syshandler = getSystemHandler(syslog, debug, LogfmtFormat())
	if syshandler != nil {
		handlers = append(handlers, syshandler)
	}

	// FileHandler
	if logfile != "" {
		if !pathExists(filepath.Dir(logfile)) {
			return nil, fmt.Errorf("Log file path doesn't exist: %s", filepath.Dir(logfile))
		}

		if !debug {
			handlers = append(
				handlers,
				log.LvlFilterHandler(
					log.LvlInfo,
					log.Must.FileHandler(logfile, LogfmtFormat()),
				),
			)
		} else {
			handlers = append(handlers, log.Must.FileHandler(logfile, LogfmtFormat()))
		}
	}

	// StderrHandler
	format := LogfmtFormat()
	if term.IsTty(os.Stderr.Fd()) {
		format = TerminalFormat()
	}

	if verbose || debug {
		if !debug {
			handlers = append(
				handlers,
				log.LvlFilterHandler(
					log.LvlInfo,
					log.StreamHandler(os.Stderr, format),
				),
			)
		} else {
			handlers = append(handlers, log.StreamHandler(os.Stderr, format))
		}
	} else {
		handlers = append(
			handlers,
			log.LvlFilterHandler(
				log.LvlWarn,
				log.StreamHandler(os.Stderr, format),
			),
		)
	}

	if customHandler != nil {
		handlers = append(handlers, customHandler)
	}

	Log.SetHandler(log.MultiHandler(handlers...))

	return Log, nil
}
func GetLogger(syslog string, logfile string, verbose bool, debug bool, customHandler log.Handler) (logger.Logger, error) {
	Log := log.New()

	var handlers []log.Handler
	var syshandler log.Handler

	// System specific handler
	syshandler = getSystemHandler(syslog, debug, LogfmtFormat())
	if syshandler != nil {
		handlers = append(handlers, syshandler)
	}

	// FileHandler
	if logfile != "" {
		if !pathExists(filepath.Dir(logfile)) {
			return nil, fmt.Errorf("Log file path doesn't exist: %s", filepath.Dir(logfile))
		}

		if !debug {
			handlers = append(
				handlers,
				log.LvlFilterHandler(
					log.LvlInfo,
					log.Must.FileHandler(logfile, LogfmtFormat()),
				),
			)
		} else {
			handlers = append(handlers, log.Must.FileHandler(logfile, LogfmtFormat()))
		}
	}

	// StderrHandler
	format := LogfmtFormat()
	if term.IsTty(os.Stderr.Fd()) {
		format = TerminalFormat()
	}

	if verbose || debug {
		if !debug {
			handlers = append(
				handlers,
				log.LvlFilterHandler(
					log.LvlInfo,
					log.StreamHandler(os.Stderr, format),
				),
			)
		} else {
			handlers = append(handlers, log.StreamHandler(os.Stderr, format))
		}
	} else {
		handlers = append(
			handlers,
			log.LvlFilterHandler(
				log.LvlWarn,
				log.StreamHandler(os.Stderr, format),
			),
		)
	}

	if customHandler != nil {
		handlers = append(handlers, customHandler)
	}

	Log.SetHandler(log.MultiHandler(handlers...))

	return Log, nil
}
// GetLogger returns a logger suitable for using as logger.Log.