litl/leeroy

Where's the logging at?

Closed this issue · 10 comments

From the readme, I couldn't paint a clear picture of where the logging output should go to (or even how to enable logging).

I noticed the logging.conf file, which is pointed to from the settings.py file, but there is no mention of the log path. Any help (as a non-python developer) would be appreciated.

Agree, the docs need some love here.

You set the logging config with the LOGGING_CONF variable in settings.py. The file format is in a kind-of-standardized-by-Python format, described here. The upside is that it's extremely flexible. The downside is that it's extremely complicated and a PITA.

Right now the default logging.conf logs to standard out. A config to log to a file might be something like this:

[formatters]
keys: simple

[handlers]
keys: console,file

[loggers]
keys: root

[formatter_simple]
format: %(levelname)s %(asctime)s %(name)s %(module)s:%(lineno)d %(message)s

[handler_console]
class: logging.StreamHandler
args: (sys.stdout,)
formatter: simple

[handler_file]
class: logging.handlers.RotatingFileHandler
args: ['/var/log/leeroy/leeroy.log','a',1000000,5]
formatter: simple

[logger_root]
level: DEBUG
handlers: console,file

That adds a rotating file handler, writing to /var/log/leeroy/leeroy.log and rotating it every 1 million bytes and keeping up to 5 files. Messages are logged both to the console and the file.

(Note, I haven't tested this exactly, but it based upon my own logging config file.)

I use the exact same logging.conf as you here, and I see just this in the console.

10.1.2.100 - - [21/Oct/2013 17:00:54] "POST /notification/github HTTP/1.1" 404 -

Nothing in the log file. Any idea how to debug this?

@rahulsom Is SERVER_NAME in your config the same as what is being passed via the Host HTTP header?

This is my settings.py

DEBUG = True
LOGGING_CONF = "logging.conf"
LOGGER_NAME = "leeroy"

SERVER_NAME = "deploy.certifydatasystems.com"

GITHUB_NOTIFICATION_SERVER_NAME = "deploy.certifydatasystems.com/leeroy/"

GITHUB_API_BASE = "https://api.github.com"

GITHUB_VERIFY = True

GITHUB_TOKEN = "...masked..."

JENKINS_URL = "https://build-vm.corp.certifydatasystems.com/hudson/"
JENKINS_USER = "...masked..."
JENKINS_PASSWORD = "...masked..."

BUILD_COMMITS = 'NEW'

REPOSITORIES = [...]

This is my apache proxies configuration:

ProxyPass /leeroy/ http://10.1.6.8:5000/
ProxyPassReverse /leeroy/ http://10.1.6.8:5000/

Ok, I think you need to set SERVER_NAME to 10.1.6.8:5000 but leave GITHUB_NOTIFICATION_SERVER_NAME as it is (although you might want/need to drop the path portion)

Thanks @joeshaw. That was it. I'll send a PR documenting how to get it to work in scenarios like mine.
Before that I need some more help.

INFO:werkzeug:10.1.2.100 - - [22/Oct/2013 10:56:28] "POST /notification/github HTTP/1.1" 500 -
ERROR:leeroy:Exception on /notification/github [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.6/dist-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.6/dist-packages/leeroy/base.py", line 97, in github_notification
    action = request.json["action"]
TypeError: 'NoneType' object is unsubscriptable

hmm, that's strange; the data coming from GitHub should be JSON. Is it possible the reverse proxy isn't passing along the POST body?

The other application being proxied by apache seems to be getting it's POST body unhindered.

Suddenly seems to be working. Sorry! I don't know how.

ok, maybe a temporary github glitch. open a new issue if you find another issue, and please do send along the PR to improve the docs!