aliyun / aliyun/aliyun-log-python-sdk

using uwsgi_handler in virtualenv cause some import error

Open
#83 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
176
Forks
119
Avg merge
3h 56m
Merged PRs (30d)
2

Description

it might not be caused by the handler, but the uwsgi module itself.

LOGGING_CONFIG = {
    'version': 1,
    'formatters': {
        'rawformatter': {
            'class': 'logging.Formatter',
            'format': '%(message)s'
        }
    },
    'handlers': {
        'sls_handler': {
            '()': 'aliyun.log.UwsgiQueuedLogHandler',
            'level': 'INFO',
            'formatter': 'rawformatter',

            # custom args:
            'end_point': settings.DATAENTRY_ENDPOINT,
            'access_key_id': base64.b64decode(settings.DATAENTRY_ACCESS_ID),
            'access_key': base64.b64decode(settings.DATAENTRY_ACCESS_KEY),
            'project': app.config["ALIYUN_LOG_PROJECT"],
            'log_store': app.config["ALIYUN_LOG_LOGSTORE"]
        },
        "file": {
            "level": "DEBUG",
            "class": "logging.handlers.TimedRotatingFileHandler",
            "filename": app.config["LOG_INFO_FILE"],
            "when": "midnight",
            "formatter": "rawformatter",
            "encoding": "utf-8",
        },
        "file_error": {
            "level": "ERROR",
            "class": "logging.handlers.TimedRotatingFileHandler",
            "when": "midnight",
            "filename": app.config["LOG_ERROR_FILE"],
            "formatter": "rawformatter",
            "encoding": "utf-8",
        },
        "console": {
            "level": "NOTSET",
            "class": "logging.StreamHandler",
            "stream": sys.stderr,
            "formatter": "rawformatter"
        }
    },
    'loggers': {
        'sls': {
            'handlers': ['sls_handler', 'file', 'console'],
            'level': 'INFO',
            'propagate': False
        },
        'file': {
            "handlers": ['console', 'file', 'file_error'],
            "level": "DEBUG",
            "propagate": False,
        }
    }
}
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1664, in <module>
    main()
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/gelin/antsophon-backend/core/log.py", line 76, in <module>
    logging.config.dictConfig(LOGGING_CONFIG)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 794, in dictConfig
    dictConfigClass(config).configure()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 576, in configure
    '%r: %s' % (name, e))
ValueError: Unable to configure handler u'sls_handler': No module named uwsgi

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the logging.config.dictConfig call in core/log.py and reproduce the traceback in the reported Python 2.7 virtualenv. Check whether the uwsgi import is required by the handler or unavailable in this environment. Done means the cause is identified and the handler either configures successfully in a supported setup or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.