0

Hello..

I have function as below to create logfile and write logs to it. It works fine in python shell. But once you convert it into sql server query, its not working. Any idea why so?

import logging
import time
from datetime import datetime
labellog = "C:\LabelLog" + datetime.now().strftime("%Y%m%d_%H%M%S")+".log"
logging.basicConfig(filename=labellog,format='%(asctime)s %(message)s',level=logging.DEBUG)

def writelogfile(a, strg):
    lbstr1 = ' function started'
    lbstr2 = ' function completed'
    if a == 1:
        logging.debug(strg+lbstr1)
    elif a == 0:
        logging.debug(strg+lbstr2)


def prntfl():
    strg = prntfl.func_name
    writelogfile(1,strg)
    global var
    var = 'This is a function'
    logging.debug(var)
    writelogfile(0,strg)
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by pyTony
0

I see no SQL in your code and the functions are never called. I would write:

def writelogfile(a, strg):
    logging.debug(strg + (' function completed', ' function started')[a])
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.