o
    s2h                     @   s    d dl Z ddlmZ dd ZdS )    N   )ErrorLogc              
   C   s   z t |trt| dt  }nt|}tjj| |d W dS  tyH } ztdt|  td|  dt|  W Y d}~dS d}~ww )z
    Log an error to the database
    
    Args:
        task_source (str): The source of the error (method, controller, view name)
        error (Exception or str): The error object or error message
    
)task_sourceerrorzFailed to log error: zOriginal error from z: N)	
isinstance	Exceptionstr	traceback
format_excr   objectscreateprint)r   r   error_messagee r   4C:\Users\Denis\Desktop\TimeStamps\ErrorLogs\utils.py	log_error   s   
&r   )r
   modelsr   r   r   r   r   r   <module>   s    