forked from open-webui/open-webui
		
	Migrate to python logging module with env var control.
This commit is contained in:
		
							parent
							
								
									d865b9fe59
								
							
						
					
					
						commit
						e6dd0bfbe0
					
				
					 15 changed files with 174 additions and 82 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,7 @@ from utils.utils import get_current_user, get_admin_user
 | 
			
		|||
from fastapi import APIRouter
 | 
			
		||||
from pydantic import BaseModel
 | 
			
		||||
import json
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from apps.web.models.users import Users
 | 
			
		||||
from apps.web.models.chats import (
 | 
			
		||||
| 
						 | 
				
			
			@ -27,6 +28,10 @@ from apps.web.models.tags import (
 | 
			
		|||
 | 
			
		||||
from constants import ERROR_MESSAGES
 | 
			
		||||
 | 
			
		||||
from config import SRC_LOG_LEVELS
 | 
			
		||||
log = logging.getLogger(__name__)
 | 
			
		||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
 | 
			
		||||
 | 
			
		||||
router = APIRouter()
 | 
			
		||||
 | 
			
		||||
############################
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +83,7 @@ async def create_new_chat(form_data: ChatForm, user=Depends(get_current_user)):
 | 
			
		|||
        chat = Chats.insert_new_chat(user.id, form_data)
 | 
			
		||||
        return ChatResponse(**{**chat.model_dump(), "chat": json.loads(chat.chat)})
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        print(e)
 | 
			
		||||
        log.exception(e)
 | 
			
		||||
        raise HTTPException(
 | 
			
		||||
            status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +100,7 @@ async def get_all_tags(user=Depends(get_current_user)):
 | 
			
		|||
        tags = Tags.get_tags_by_user_id(user.id)
 | 
			
		||||
        return tags
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        print(e)
 | 
			
		||||
        log.exception(e)
 | 
			
		||||
        raise HTTPException(
 | 
			
		||||
            status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT()
 | 
			
		||||
        )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue