# https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial
import logging
import sys


def get_logger(name):
    """
    https://stackoverflow.com/questions/22807972/python-best-practice-in-terms-of-logging
    https://stackoverflow.com/questions/28330317/print-timestamp-for-logging-in-python
    https://docs.python.org/3/library/logging.html#formatter-objects
    https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial
    https://docs.python.org/3.6/howto/logging.html#logging-to-a-file
    :param name: logger name
    :return: a configured logger
    """
    formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(funcName)s line:%(lineno)s %(message)s',
                                  datefmt='%Y-%m-%d %H:%M:%S')

    logger = logging.getLogger(name)
    logger.setLevel(logging.DEBUG)

    # add one or more handlers

    # log to file
    # mode 'a' append, not 'w' write
    handler = logging.FileHandler('./data/output/fib.log', mode='a')
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    # log to terminal stdout
    screen_handler = logging.StreamHandler(stream=sys.stdout)
    screen_handler.setFormatter(formatter)
    logger.addHandler(screen_handler)

    return logger


@@ -878,54 +878,35 @@
  to 
-file%0A    # mode 'a' append, not 'w' write%0A    
+terminal stdout%0A    screen_
 hand
@@ -923,20 +923,22 @@
 ing.
-File
+Stream
 Handler(
 './d
@@ -937,47 +937,38 @@
 ler(
-'./data/output/fib.log', mode='a')%0A    
+stream=sys.stdout)%0A    screen_
 hand
@@ -1017,16 +1017,23 @@
 Handler(
+screen_
 handler)
@@ -1042,44 +1042,434 @@
     
-# log to terminal stdout%0A    screen_
+%22%22%22%0A    comment out log to file.%0A    instead log to stream only.%0A    let program user decide if they want to pipe stream output to a file e.g.%0A        python3 fibonacci.py %3E%3E ../fib.log%0A        python3 -m unittest %3E%3E ../test.log%0A    references%0A    %22logging in an application%22%0A    https://docs.python-guide.org/writing/logging/%0A    https://12factor.net/logs%0A    %22%22%22%0A    # log to file%0A    # mode 'a' append, not 'w' write%0A    # 
 hand
@@ -1478,38 +1478,36 @@
 r = logging.
-Stream
+File
 Handler(
 stream=sys.s
@@ -1498,38 +1498,49 @@
 ler(
-stream=sys.stdout)%0A    screen_
+'./data/output/fib.log', mode='a')%0A    # 
 hand
@@ -1562,32 +1562,34 @@
 r(formatter)%0A   
+ #
  logger.addHandl
@@ -1583,39 +1583,32 @@
 gger.addHandler(
-screen_
 handler)%0A%0A    re

comment out log to file.