<p>Print statements can only do so much. You also need to log to files if you want to debug something that is in production. That is why in this series of videos we'll show you how to set up logging for your project and to also show you how it works.</p>

1 - Introduction
2 - Format
3 - Level
4 - Files
5 - Error
6 - Rich
7 - Often

This video has three files. To run it from the command line you need to be sure that you're in a virtualenv that has pandas installed.


import sys 

from summarise import summary

if __name__ == "__main__":
    # this line will grab the ticker argument
    ticker = sys.argv[1]

    # this line will take the ticker and do the analysis
    print(f"The average stock price is {summary(ticker)}")


from fetch import download_data

def summary(ticker):
    dataf = download_data()
    return dataf[ticker].mean()


import pandas as pd

def download_data():
    url = 'https://calmcode.io/datasets/stocks.csv'
    reutrn pd.read_csv(url)

You'll notice that everything runs fine when we run;

python job.py KLM

But things go wrong when we run;

python job.py GOOG

The debugging could be made easier if we had logging around. Sure, we could also use the python debugger but logging is a good habbit either way. In this series of videos we're going to explain how to set it up.