o
    $i]                     @   s>   d dl Z d dlmZ d dlmZ dedededefdd	ZdS )
    N)open_log)StreamRedirectorstdout_filepathstderr_filepathrotation_bytesrotation_backup_countc                 C   sd   | rt | ||dd |rt |||dd tj }tj }t|dddt_t|dddt_dS )a  This function sets up redirection for stdout and stderr if needed, based on the given rotation parameters.

    params:
    stdout_filepath: the filepath stdout will be redirected to; if empty, stdout will not be redirected.
    stderr_filepath: the filepath stderr will be redirected to; if empty, stderr will not be redirected.
    rotation_bytes: number of bytes which triggers file rotation.
    rotation_backup_count: the max size of rotation files.
    FT)
unbufferedclosefdN)r   redirect_stdoutredirect_stderrsysstdoutfilenostderrr   )r   r   r   r   stdout_filenostderr_fileno r   W/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/_private/logging_utils.py redirect_stdout_stderr_if_needed   s(   
	
r   )r   ray._private.utilsr   ray._rayletr   strintr   r   r   r   r   <module>   s    