Skip to content

Newsletter

Help Center

Categories
< All Topics
Print

VSCode Parameters and Logs

VSCode is the text editor of choice at COSMOS

Lauch.json

Adding parameters

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Sent & Tox",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\Main.py",
            "console": "integratedTerminal",
            "args": ["-p", "True",]
        },
    ]
}

Running & Creating log file

Windows: 

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Sent & Tox",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\Main.py",
            "console": "integratedTerminal",
            "args": [ "|", "tee", "Logs\\Log_%date:~4,2%-%date:~7,2%-%date:~10,4%.log"]
        },
    ]
}

Linux:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Main",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/main.py",
            "console": "integratedTerminal", 
            "args": ["|", "tee", "/home/cosmosadmin/YoutubeDownload/Logs/`date +%Y-%m-%d`.log"]
},

Tee command

The tee command is used to display output from a terminal command while also capturing the output to a text file. This is useful when trying to run a python script and also logging all it’s output to a file. 

The tee command is available in Linux but not in windows. To get it working in Windows:

  1. install this: http://gnuwin32.sourceforge.net/packages/coreutils.html
  2. Then you need to add the ‘bin’ from the installation path to the env variables in windows. 
Table of Contents

© 2024 Collaboratorium for Social Media and Online Behavioral Studies