Example #1
0
func (p *Configuration) Backup() (string, []string) {
	utils.Mkdirs("tmp/backup", 0700)
	now := time.Now().Format("20060102150405")
	name := fmt.Sprintf("tmp/backup/%s_%s.sql", now, p.Name)
	switch p.Driver {
	case "postgres":
		return "pg_dump", []string{"-U", p.User, "-h", p.Host, "-p", strconv.Itoa(p.Port), "-d", p.Name, "-f", name}
	default:
		return "echo", []string{"unknown database."}
	}
}
Example #2
0
func Open(env string) Logger {
	log_d := "log"

	if cmd.IsProduction(env) {
		if log, err := NewSyslogLogger("ksana", INFO); err == nil {
			return log
		} else {
			fmt.Fprintf(os.Stderr, "error on create syslog logger: %v", err)
		}

		utils.Mkdirs(log_d, 0700)

		if log, err := NewFileLogger(fmt.Sprintf("%s/%s.log", log_d, env), INFO); err == nil {
			return log
		} else {
			fmt.Fprintf(os.Stderr, "error on create file logger: %v", err)
		}
		return NewStdoutLogger(INFO)
	}

	return NewStdoutLogger(DEBUG)
}