コード例 #1
0
ファイル: logs.go プロジェクト: giancosta86/moondeploy
func ensureLogsDirectory(logsDirectory string) {
	err := os.MkdirAll(logsDirectory, 0700)
	if err != nil {
		log.Error("Cannot create the logs directory ('%v'). %v", logsDirectory, err)
		os.Exit(v3.ExitCodeError)
	}
}
コード例 #2
0
ファイル: app.go プロジェクト: giancosta86/moondeploy
func (app *App) SaveReferenceDescriptor() (referenceDescriptorSaved bool) {
	referenceDescriptor, err := app.GetReferenceDescriptor()
	if err != nil {
		log.Warning("Cannot save the reference descriptor: %v", err)
		return false
	}

	log.Info("Saving the reference descriptor as the local descriptor...")
	referenceDescriptorBytes, err := referenceDescriptor.GetBytes()
	if err != nil {
		log.Error("Could not serialize the reference descriptor: %v", err)
		return false
	}

	err = ioutil.WriteFile(app.localDescriptorPath, referenceDescriptorBytes, 0600)
	if err != nil {
		log.Error("Could not save the reference descriptor: %v", err)
		return false
	}

	log.Notice("Reference descriptor saved")
	return true
}
コード例 #3
0
func getMoonSettings() *MoonSettings {
	if moonSettings != nil {
		return moonSettings
	}

	rawMoonSettings := getRawMoonSettings()

	moonSettings = &MoonSettings{}

	if rawMoonSettings.LocalDirectory != "" {
		moonSettings.localDirectory = rawMoonSettings.LocalDirectory
	} else {
		userDir, err := caravel.GetUserDirectory()
		if err != nil {
			log.Error("Cannot retrieve the user's directory")
			os.Exit(v3.ExitCodeError)
		}

		moonSettings.localDirectory = filepath.Join(userDir, defaultLocalDirName)
	}

	moonSettings.galleryDirectory = filepath.Join(moonSettings.localDirectory, galleryDirName)
	moonSettings.logsDirectory = filepath.Join(moonSettings.localDirectory, logsDirName)

	if rawMoonSettings.BufferSize > 0 {
		moonSettings.bufferSize = rawMoonSettings.BufferSize
	} else {
		moonSettings.bufferSize = defaultBufferSize
	}

	moonSettings.loggingLevel = parseLoggingLevel(rawMoonSettings.LoggingLevel)

	moonSettings.skipAppOutput = rawMoonSettings.SkipAppOutput

	if 0 <= rawMoonSettings.BackgroundColor && rawMoonSettings.BackgroundColor <= 255 {
		moonSettings.backgroundColor = rawMoonSettings.BackgroundColor
	} else {
		moonSettings.backgroundColor = defaultBackgroundColor
	}

	if 0 <= rawMoonSettings.ForegroundColor && rawMoonSettings.ForegroundColor <= 255 {
		moonSettings.foregroundColor = rawMoonSettings.ForegroundColor
	} else {
		moonSettings.foregroundColor = defaultForegroundColor
	}

	return moonSettings
}
コード例 #4
0
ファイル: logs.go プロジェクト: giancosta86/moondeploy
func createLogFile(logsDirectory string) *os.File {
	now := time.Now()

	logFileName := fmt.Sprintf("MoonDeploy - %d-%d-%d %d-%d-%d %d.log",
		now.Year(),
		now.Month(),
		now.Day(),
		now.Hour(),
		now.Minute(),
		now.Second(),
		now.Nanosecond())

	logFilePath := filepath.Join(logsDirectory, logFileName)

	logFile, err := os.Create(logFilePath)
	if err != nil {
		log.Error("Cannot create the log file '%v'! %v", logFilePath, err.Error())
		os.Exit(v3.ExitCodeError)
	}

	return logFile
}
コード例 #5
0
func (userInterface *TerminalUserInterface) ShowError(message string) {
	userInterface.Hide()

	log.Error(message)
}
コード例 #6
0
ファイル: main.go プロジェクト: giancosta86/moondeploy
func exitWithError(err error) {
	log.Error(err.Error())
	os.Exit(v3.ExitCodeError)
}