Esempio n. 1
0
File: main.go Progetto: uiri/brog
func doInit() {
	fmt.Println(brush.DarkGray("A dark geometric shape is approaching..."))
	errs := brogger.CopyBrogBinaries()
	if len(errs) != 0 {
		printPreBrogError("Couldn't inject brog nanoprobes.\n")
		for _, err := range errs {
			printPreBrogError("Message : %v.\n", err)
		}
		return
	}

	brog, err := brogger.PrepareBrog(false)
	if len(errs) != 0 {
		printPreBrogError("Couldn't prepare brog structure.\n")
		printPreBrogError("Message : %v.\n", err)
		return
	}
	brog.Ok("Initiliazing a brog. Resistance is futile.")

	defer closeOrPanic(brog)
	brog.Ok("Brog nanoprobes implanted.")
}
Esempio n. 2
0
func makeLogMux(conf *Config) (*logMux, error) {

	fileVerb, err := getVerbosityLevel(conf.LogFileVerbosity)
	if err != nil {
		return nil, fmt.Errorf("log file verbosity, %v", err)
	}
	consoleVerb, err := getVerbosityLevel(conf.ConsoleVerbosity)
	if err != nil {
		return nil, fmt.Errorf("console verbosity, %v", err)
	}

	filename := conf.LogFilename

	file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0640)
	if os.IsNotExist(err) {
		file, err = os.Create(filename)
	}
	if err != nil {
		return nil, fmt.Errorf("opening log file %s, %v", filename, err)
	}

	debugPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.Blue("DEBUG"),
		brush.DarkGray("]"))

	watchPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.DarkCyan("WATCH"),
		brush.DarkGray("]"))

	infoPfx := fmt.Sprintf(" %s%s%s ",
		brush.DarkGray("["),
		brush.Green("INFO"),
		brush.DarkGray("]"))

	warnPfx := fmt.Sprintf(" %s%s%s ",
		brush.DarkGray("["),
		brush.Yellow("WARN"),
		brush.DarkGray("]"))

	errPfx := fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.Red("ERROR"),
		brush.DarkGray("]"))

	return &logMux{
		logFile:        file,
		debugFile:      log.New(file, "[DEBUG] ", log.LstdFlags),
		watchFile:      log.New(file, "[WATCH] ", log.LstdFlags),
		infoFile:       log.New(file, " [INFO] ", log.LstdFlags),
		warnFile:       log.New(file, " [WARN] ", log.LstdFlags),
		errorFile:      log.New(file, "[ERROR] ", log.LstdFlags),
		debugConsole:   log.New(os.Stdout, debugPfx, log.LstdFlags),
		watchConsole:   log.New(os.Stdout, watchPfx, log.LstdFlags),
		infoConsole:    log.New(os.Stdout, infoPfx, log.LstdFlags),
		warnConsole:    log.New(os.Stdout, warnPfx, log.LstdFlags),
		errorConsole:   log.New(os.Stderr, errPfx, log.LstdFlags),
		fileVerbose:    fileVerb,
		consoleVerbose: consoleVerb,
	}, nil
}
Esempio n. 3
0
File: main.go Progetto: uiri/brog
    brog create [name]    Creates a blank post in file [name], in the
                          location specified by the config file.

    brog page [name]      Creates a blank page in file [name], in the
                          location specified by the config file.

    brog help             Shows this message.

    brog version          Prints the current version of brog.
`
)

var (
	errPfx = fmt.Sprintf("%s%s%s ",
		brush.DarkGray("["),
		brush.Red("ERROR"),
		brush.DarkGray("]"))
)

func main() {
	commands := os.Args[1:]
	for i, arg := range commands {
		switch arg {
		case Init:
			doInit()
			return
		case Server:
			if len(commands) > i+1 {
				doServer(commands[i+1] == "prod")
			} else {