(self, step)
Output useful information to stdout and the log file if debugging is required.
        :step: Print the corresponding step in the log
Output useful information to stdout and the log file if debugging is required.
        :step: Print the corresponding step in the log
Output useful information to stdout and the log file if debugging is required . : step : Print the corresponding step in the log
def _print_log(self, step):
        """
        Output useful information to stdout and the log file if debugging is required.
        :step: Print the corresponding step in the log
        """
        
        # Set mode to append to log file
        mode = 'a'

        if self.logfile is None:
            # Increment log counter for the class. Each instance of the class generates a new log.
            self.__class__.log_no += 1

            # Create a log file for the instance
            # Logs will be stored in ..\logs\SKLearn Log <n>.txt
            self.logfile = os.path.join(os.getcwd(), 'logs', 'Common Functions Log {}.txt'.format(self.log_no))
        
        if step == 1:
            # Output log header
            output = "\nCommonFunction Log: {0} \n\n".format(time.ctime(time.time()))
            # Set mode to write new log file
            mode = 'w'
                                
        elif step == 2:
            # Output the execution parameters to the terminal and log file
            output = "Execution parameters: {0}\n\n".format(self.kwargs) 
        
        elif step == 3:
            # Output the request data frame to the terminal and log file
            output = "REQUEST: {0} rows x cols\nSample Data:\n\n".format(self.request_df.shape)
            output += "{0}\n...\n{1}\n\n".format(self.request_df.head().to_string(), self.request_df.tail().to_string())
        
        elif step == 4:
            # Output the response data frame to the terminal and log file
            output = "RESPONSE: {0} rows x cols\nSample Data:\n\n".format(self.response_df.shape)
            output += "{0}\n...\n{1}\n\n".format(self.response_df.head().to_string(), self.response_df.tail().to_string())
        
        elif step == 5:
            # Output the table description if the call was made from the load script
            output = "TABLE DESCRIPTION SENT TO QLIK:\n\n{0} \n\n".format(self.table)
        
        elif step == 6:
            # Message when a pretrained model is loaded from path
            output = "Model '{0}' loaded from path.\n\n".format(self.name)
        
        elif step == 7:
            # Outpyt the feature definitions for the model
            output = "Feature definitions for model {0}:\n{1}\n\n".format(self.name, self.features_df.values.tolist())

        sys.stdout.write(output)
        with open(self.logfile, mode, encoding='utf-8') as f:
            f.write(output)
def _print_log ( self , step ) : # Set mode to append to log file mode = 'a' if self . logfile is None : # Increment log counter for the class. Each instance of the class generates a new log. self . __class__ . log_no += 1 # Create a log file for the instance # Logs will be stored in ..\logs\SKLearn Log <n>.txt self . logfile = os . path . join ( os . getcwd ( ) , 'logs' , 'Common Functions Log {}.txt' . format ( self . log_no ) ) if step == 1 : # Output log header output = "\nCommonFunction Log: {0} \n\n" . format ( time . ctime ( time . time ( ) ) ) # Set mode to write new log file mode = 'w' elif step == 2 : # Output the execution parameters to the terminal and log file output = "Execution parameters: {0}\n\n" . format ( self . kwargs ) elif step == 3 : # Output the request data frame to the terminal and log file output = "REQUEST: {0} rows x cols\nSample Data:\n\n" . format ( self . request_df . shape ) output += "{0}\n...\n{1}\n\n" . format ( self . request_df . head ( ) . to_string ( ) , self . request_df . tail ( ) . to_string ( ) ) elif step == 4 : # Output the response data frame to the terminal and log file output = "RESPONSE: {0} rows x cols\nSample Data:\n\n" . format ( self . response_df . shape ) output += "{0}\n...\n{1}\n\n" . format ( self . response_df . head ( ) . to_string ( ) , self . response_df . tail ( ) . to_string ( ) ) elif step == 5 : # Output the table description if the call was made from the load script output = "TABLE DESCRIPTION SENT TO QLIK:\n\n{0} \n\n" . format ( self . table ) elif step == 6 : # Message when a pretrained model is loaded from path output = "Model '{0}' loaded from path.\n\n" . format ( self . name ) elif step == 7 : # Outpyt the feature definitions for the model output = "Feature definitions for model {0}:\n{1}\n\n" . format ( self . name , self . features_df . values . tolist ( ) ) sys . stdout . write ( output ) with open ( self . logfile , mode , encoding = 'utf-8' ) as f : f . write ( output )