Start implementing a logger
This commit is contained in:
		@@ -192,8 +192,8 @@ func (e *EnvironmentsServer) Get(ctx context.Context, in *proto.GetOptions) (*pr
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *EnvironmentsServer) List(in *proto.ListOptions, stream proto.Environments_ListServer) error {
 | 
					func (e *EnvironmentsServer) List(in *proto.ListOptions, stream proto.Environments_ListServer) error {
 | 
				
			||||||
	log := e.logInstance
 | 
						logInstance := e.logInstance
 | 
				
			||||||
	log.WithValues("user_id", in.GetOwnerId().GetUuid())
 | 
						log := logInstance.WithValues("user_id", in.GetOwnerId().GetUuid())
 | 
				
			||||||
	ctx := logr.NewContext(stream.Context(), log)
 | 
						ctx := logr.NewContext(stream.Context(), log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	environment := &controllers.Environemnt{
 | 
						environment := &controllers.Environemnt{
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								main.go
									
									
									
									
									
								
							@@ -52,11 +52,6 @@ func main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func server(params Serve) error {
 | 
					func server(params Serve) error {
 | 
				
			||||||
	// Make sure the download dir exists
 | 
						// Make sure the download dir exists
 | 
				
			||||||
	if err := os.MkdirAll(params.DownloadDir, 0777); err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Init a logger
 | 
					 | 
				
			||||||
	var log logr.Logger
 | 
						var log logr.Logger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	zapLog, err := zap.NewDevelopment()
 | 
						zapLog, err := zap.NewDevelopment()
 | 
				
			||||||
@@ -64,10 +59,17 @@ func server(params Serve) error {
 | 
				
			|||||||
		panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
 | 
							panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	log = zapr.NewLogger(zapLog)
 | 
						log = zapr.NewLogger(zapLog)
 | 
				
			||||||
	log.Info("enabled")
 | 
					
 | 
				
			||||||
 | 
						if err := os.MkdirAll(params.DownloadDir, 0777); err != nil {
 | 
				
			||||||
 | 
							log.Error(err, "Coulnd't create a download dir")
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Init a logger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	controller, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{})
 | 
						controller, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Error(err, "Coulnd't start a kube manager")
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user