Move logging to separate file
This commit is contained in:
		@@ -41,20 +41,6 @@ func main() {
 | 
			
		||||
	al.Start()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func initLogging() *os.File {
 | 
			
		||||
	if len(logFilePath) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	f, err := os.OpenFile(logFilePath, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0600)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.SetOutput(f)
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func handleErrors() {
 | 
			
		||||
	if err := recover(); err != nil {
 | 
			
		||||
		log.Printf("Crashed with unexpected error: %v!\n", err)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								cmd/after-lock/logging.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								cmd/after-lock/logging.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func initLogging() *os.File {
 | 
			
		||||
	if len(logFilePath) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	f, err := os.OpenFile(logFilePath, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0600)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.SetOutput(f)
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user