Exemplo n.º 1
0
// Initialize the Logger objects for logging to config location
func InitializeLoggers(level LogLevel) error {

	// Create a new logger
	eventLogger = new(Logger)
	eventLogger.Level = level

	// Open a handle to the log file
	path, err := config.CrateLoggingPath()
	if err != nil {
		return err
	}

	// Set the output path (opening the file and configuring the writer)
	return eventLogger.SetOutputPath(path)
}
Exemplo n.º 2
0
		Ω(err).Should(BeNil())

		// Setup the fake User home directory for testing
		testHome = filepath.Join(testRoot, "Users", "jdoe")
		err = os.MkdirAll(testHome, 0755)
		Ω(err).Should(BeNil())

		if runtime.GOOS == "windows" {
			err = os.Setenv("USERPROFILE", testHome)
			Ω(err).Should(BeNil())
		} else {
			err = os.Setenv("HOME", testHome)
			Ω(err).Should(BeNil())
		}

		logPath, err = config.CrateLoggingPath()
		Ω(err).Should(BeNil())

	})

	AfterEach(func() {
		// Remove the test file system
		err = os.RemoveAll(testRoot)
		Ω(err).Should(BeNil())

		// Unset the environment variables
		if runtime.GOOS == "windows" {
			err = os.Unsetenv("USERPROFILE")
			Ω(err).Should(BeNil())
		} else {
			err = os.Unsetenv("HOME")