use additional loki logger #48
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
    "cmake.ignoreCMakeListsMissing": true
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 Submodule backend/deployment updated: 4f0a0289fc...904f16bfc0
									
								
							@@ -21,11 +21,19 @@ debug = os.getenv('DEBUG', "false") == "true"
 | 
				
			|||||||
if os.getenv('KUBERNETES_SERVICE_HOST', None) is not None:
 | 
					if os.getenv('KUBERNETES_SERVICE_HOST', None) is not None:
 | 
				
			||||||
    # in that case we want to log to stdout and also to loki
 | 
					    # in that case we want to log to stdout and also to loki
 | 
				
			||||||
    from loki_logger_handler.loki_logger_handler import LokiLoggerHandler
 | 
					    from loki_logger_handler.loki_logger_handler import LokiLoggerHandler
 | 
				
			||||||
 | 
					    loki_url = os.getenv('LOKI_URL')
 | 
				
			||||||
 | 
					    if loki_url is None:
 | 
				
			||||||
 | 
					        raise ValueError("LOKI_URL environment variable is not set")
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    loki_handler = LokiLoggerHandler(
 | 
					    loki_handler = LokiLoggerHandler(
 | 
				
			||||||
        url=os.getenv('LOKI_URL', 'http://loki:3100'),
 | 
					        url = loki_url,
 | 
				
			||||||
        labels={'app': 'anyway', 'env': 'production' if debug else 'staging'}
 | 
					        labels = {'app': 'anyway', 'environment': 'production' if debug else 'staging'}
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					    print(f"Logging to Loki at {loki_url} with {loki_handler.labels} and {debug=}")
 | 
				
			||||||
    if debug:
 | 
					    if debug:
 | 
				
			||||||
 | 
					        # we need to silence the debug logs made by the loki handler
 | 
				
			||||||
 | 
					        logging.getLogger('urllib3.connectionpool').setLevel(logging.INFO)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        logging.basicConfig(
 | 
					        logging.basicConfig(
 | 
				
			||||||
            level=logging.DEBUG,
 | 
					            level=logging.DEBUG,
 | 
				
			||||||
            handlers=[loki_handler, logging.StreamHandler()]
 | 
					            handlers=[loki_handler, logging.StreamHandler()]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user