简体   繁体   中英

TypeError: openlog() takes no keyword arguments

I am trying to write to syslog in one of my scripts. Here is the code for logger.py:

from __future__ import print_function
import os
import sys
import syslog
import urllib
import datetime

def log(msg, level="info"):
    msg = safe(msg)
    if os.environ.get('debug'):
        debugmsg = "{0} {1}".format(datetime.datetime.now(), msg)
        print(debugmsg, file=sys.stderr)
    syslog.openlog(ident=__file__,logoption=syslog.LOG_PID,facility=syslog.LOG_LOCAL0)
    syslog.syslog(level, msg)

def safe(str):
    return urllib.unquote_plus(str)

When I go to test the log function via logger.log("Hello world!") , the interpreter throws TypeError: openlog() takes no keyword arguments .

Any insight?

This could be a problem with an older version of python. See this and that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM