{ "info": { "author": "Morgan Fainberg", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [], "description": "python-rfc5424-logging-formatter\n================================\n\nA Logging Formatter for Python's logging module to properly handle Syslog RFC5424 messages\n\n\nWhat is provided by this formatter\n----------------------------------\n\nA derived formatter than allows for isotime specification\nfor full RFC5424 compliancy (with corrected TZ format)\n\nFor a \"proper\" ISOTIME format, use \"%(isotime)s\" in a\nformatter instance of this class or a class derived from\nthis class. This is for a work-around where strftime\nhas no mechanism to produce timezone in the format of\n\"-08:00\" as required by RFC5424.\n\nThe '%(isotime)s' replacement will read in the record\ntimestamp and try and reparse it. This really is a\nproblem with RFC5424 and strftime. I am unsure if this\nwill be fixed in the future (in one or the other case)\n\nThis formatter has an added benefit of allowing for\n'%(hostname)s' to be specified which will return a '-'\nas specified in RFC5424 if socket.gethostname() returns\nbad data (exception).\n\n\nRFC5424 Format\n--------------\n\nRFC: http://tools.ietf.org/html/rfc5424\n\n__The RFC5424 Format should only be used when talking to a Syslog server\nover the network stack. Specifically the Linux KSyslog implementation\nstill uses RFC3164 format (and something akin to RSyslog still adheres\nto that)__\n\nThe RFC5424 format string should look somthing like:\n```\n%(isotime)s %(hostname)s %(name)s %(process)d - - %(message)s\n```\n\nThe section after the two \"- -\" is technically the message\nsection, and can have any data applied to it e.g.:\n```\n <...> %(levelname)s [%(module)s %(funcName)s] %(message)s\n```\n\nThe '- -' section is the \"msg ID\" and \"Structured-Data\" Elements,\nrespectively\n\n\nExample usage of the formatter\n-------------------------------\n\n```python\n\n import logging\n\n logger = logging.getLogger('rfc5424_example')\n handler = logging.handlers.SysLogHandler(address=
)\n format = '%(isotime)s %(hostname)s %(name)s %(process)d - - %(message)s'\n formatter = RFC5424Syslog(format)\n\n handler.setFormatter(formatter)\n\n logger.addHandler(handler)\n\n logger.info('RFC5424 Log Message Format in use')\n```\n\nLicense\n-------\n\n Copyright (C) 2013 Morgan Fainberg and Metacloud, Inc\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see