I am working on a code that runs a scheduled job and take screenshot on the chromedriver and email it. I am trying to find a way to capture the console output to a file and later email it. Below is a code snippet for the scheduler and the screenshot module.

This is my scheduler,

```
import schedule
import time
from datetime import datetime
from screenshot import screenshot

def job():
    print("Launching scresnshot")
    screenshot()

```

My screenshot code,

```
import time
from Screenshot import Screenshot_Clipping
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from email_it import email_it
from environmental_variables import environmental_variables
from error_alert_email import error_alert_email
from selenium import webdriver

def screenshot():

    ob=Screenshot_Clipping.Screenshot()

    chrome_options = Options()

    chrome_options.add_argument('--start-maximized')    
    chrome_options.add_argument('--start-fullscreen')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')

    driver = webdriver.Chrome(executable_path = r"C:\Users\me\Documents\Projects\chromedriver.exe")
    print('Confirming visibility...')
    WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.ID, visibility_element)))

    print('taking screenshot...')
    img_url=ob.full_Screenshot(driver, path = path, image_name = label)

    print('closing driver...')    
    driver.close()

screenshot()

```

**MY console output**

PS: `C:\Users\Documents\Projects\> python .\src\scheduler.py`

```
DevTools listening on ws://124.1.0.1:76532/devtools/browser/785b0a24-7638-4b2d-a2da-ae62a65891f6
Opening url...
[ERROR:device_event_log_impl.cc(214)] [15:07:41.359] USB: usb_device_handle_win.cc:1054 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Logging in...
Confirming visibility...
Taking screenshot...
Sending mail...
Message sent!
Closing driver...

```