summaryrefslogtreecommitdiffstats
path: root/tests/unit/test_log.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge "python3: python3 binary/text data compatbility"Jenkins2013-06-031-2/+2
|\
| * python3: python3 binary/text data compatbilityChuck Short2013-05-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Python3 enforces the distinction between byte strings far more rigorously than Python 2 does; binary data cannot be automatically coerced to or from text data. Use six to provide a fake file object for textual data. It provides an alias for StringIO.StringIO in python2 and io.StringIO in python3 Change-Id: I65897bb0cca2cbeb5819a769b98645c9eb066401 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* | Enable hacking H402 testSergey Lukjanov2013-06-031-1/+1
|/ | | | | | H402 one line docstring needs punctuation Change-Id: Ie848453cace318d8310cdf0234c512f4c1121119
* Enable hacking H403 testSergey Lukjanov2013-05-301-1/+2
| | | | | | H403 multi line docstring end on new line Change-Id: I33249651026b54ef346214965e909835288bb14e
* Remove the notifier and its dependencies from log.pyDavanum Srinivas2013-05-141-1/+2
| | | | | | | | | Move the code related to the publish error handler out of the log module so its easier for other projects to consume it Fixes LP #1179528 Change-Id: Ibf28ba17f81b5ddeda653f6a3501ecac18ffcd42
* Deprecate log_format and change default to NoneAndrew Laski2013-05-011-8/+23
| | | | | | | | | | | | | | | | | | Commit 3e71cc4c8c7e08784f44c2e337a585e562b93ec5 fixed an issue with ignoring log_format, but changed the default logging formatter. This led to being unable to use the former context aware formatter without configuring log_format='' explicitly. This change sets log_format to None so that the default is a context aware formatter, but setting log_format works as intended. Additionally, since log_format is mutually exclusive with some of the other config formatting options, such as logging_default_format_string, it should be deprecated. Bug 1167388 Change-Id: I281ed7fe3448403f27a4cd318fc21915027906cc
* Support for lazily instantiated loggersDavanum Srinivas2013-04-091-4/+19
| | | | | | | | | | | | As part of code review for LP #1161031, there was a suggestion to lazily instantiate the logger in oslo. The use case was when creating LOG at a module level when we have not yet called logging.setup, we needed a way to delay creating actual loggers Added a handlers property in ContextAdapter so the existing testcase can be used for lazy loggers as well Change-Id: Iae2e379f8a0d2d38836645e7648294dee97deaaa
* Gracefully handle errors in logging config filesMark McLoughlin2013-03-221-0/+48
| | | | | | | | | | | | | | | | | | | | | | Fixes bug #1154245 If the parameter to the --log-config option cannot be loaded by the logging.config.fileConfig() function, you get an exception like this raised: NoSectionError: No section: 'formatters' which doesn't do much to help users understand the error. Improve the situation by wrapping the error in a custom exception type giving this: LogConfigError: Error loading logging config /etc/logging.conf: No section: 'formatters' Also add some tests to check we raise this error under the most common failure conditions. Change-Id: I6ad2eb4867213b6356ce43d75da50218d1b498f6
* Use oslo-config-2013.1b3Mark McLoughlin2013-02-171-1/+2
| | | | | | | | | | | | | | | The cfg API is now available via the oslo-config library, so switch to it and remove the copied-and-pasted version. Add the 2013.1b3 tarball to tools/pip-requires - this will be changed to 'oslo-config>=2013.1' when oslo-config is published to pypi. This will happen in time for grizzly final. Remove the 'deps = pep8==1.3.3' and 'deps = pyflakes' from tox.ini as it means all the other deps get installed with easy_install which can't install oslo-config from the URL. Change-Id: I4815aeb8a9341a31a250e920157f15ee15cfc5bc
* Don't use subprocess for testing excepthookJason Kölker2013-02-131-18/+18
| | | | | | | | | * The previous test tested the funtionality of the excepthook using subprocess.popen. We don't need to test the interpreter, just test that our excepthook is installed and test that it functions as expected. * Fix Bug 1124617 Change-Id: Ifd8d35b842b913003100097d917d30bf66e5cb7a
* Use testtools as test base class.Monty Taylor2013-01-241-5/+2
| | | | | | | | | | | | | On the path to testr migration, we need to replace the unittest base classes with testtools. Replace tearDown with addCleanup, addCleanup is more resilient than tearDown. The fixtures library has excellent support for managing and cleaning tempfiles. Use it. Replace skip_ with testtools.skipTest Part of blueprint grizzly-testtools. Change-Id: I45e11bbb1ff9b31f3278d3b016737dcb7850cd98
* Move logging config options into the log moduleMark McLoughlin2013-01-211-5/+56
| | | | | | | | | | | | | | | | | | We learned a lesson in Nova - it's best to declare and use config options within a single module if possible. Globally declared and use config options grow like weeds and it becomes harder to find out if, where and how individual options are used. Strangely, in cfg itself, we randomly declare a bunch of logging options which are only used within the openstack.common.log module - let's move the options there and remove the CommonConfigOpts class before they become part of the API we commit to when oslo-config is released. A minor detail in the patch - the logfile and logdir options are already deprecated in favour of log_file and log_dir, but we never got around to removing all other traces of the deprecated options. Change-Id: I3913ea54465658d93dc56e014dfe5d911b0541d6
* Fixes import order errorsZhongyue Luo2013-01-181-1/+1
| | | | Change-Id: I3e35230dd2d96ab9f5a8c11b9ec1cd8d2d00e347
* Verbose should not enable debug level loggingDavanum Srinivas2013-01-121-1/+7
| | | | | | | | | | | | | Fixes LP #989269 Currently setting --verbose in will still allow DEBUG level message to be logged to python logger object. we need to check for --debug first (set DEBUG level), then --verbose (set INFO level) and if neither is set then set default to WARNING DocImpact Change-Id: Ic9e3cb5979b2d7283552ad3a461870373f45a239
* Allow nova and others to override some logging defaultsDavanum Srinivas2012-12-061-0/+29
| | | | | | | | | | | | - In log.py, indicate that logging module allows tweaking of just logging_context_format_string option - In cfg.py, add a method that can alter the default given the options and new default - add testcases for log.set_defaults and cfg.set_defaults Fixes LP #1083218 Change-Id: Iefdbce8505eb7a07f2b59d4ed7564b0146f1b0cd
* Fix the log test so it uses the available context fields.Angus Salkeld2012-11-131-0/+7
| | | | | | | | | | | | | | | | | | logging_context_format_string in log.py references fields that don't exist in the common/context.py so we get errors like: --- File "/usr/lib64/python2.7/logging/__init__.py", line 467, in format s = self._fmt % record.__dict__ KeyError: 'project_id' Logged from file test_log.py, line 42 --- We could change the defaults in log.py but that might cause too much disruption to other projects. Change-Id: Ic3f6039baccb522b5eb2462a87b792c226ca13ef
* Restore proper LoggerTestCaseEric Windisch2012-11-051-6/+8
| | | | | | | | | | | | | | | | | | Addresses bug #1075022 Addresses bug #1075028 LoggerTestCase was no longer running as another test was created with this name (presumably due to copy-paste) The duplicate has been renamed to a more appropriate name: LogLevelTestCase. Because LoggerTestCase was not executing, bitrot has occurred. This patch also addresses those resultant test failures. Change-Id: I4f3820ba748d20606bb484d0adbfe678fa1fa38d
* Use pep8 v1.3.3Zhongyue Luo2012-09-131-1/+1
| | | | | | | Fixed indents which violate pep8 1.3.3 Also added .mailmap file to coalesce commits Change-Id: Ia7a788a28e6c0fd9cb52fb7ea477cddd7d589e58
* Merge "Fix meaningless test case"Jenkins2012-08-061-1/+1
|\
| * Fix meaningless test caseMate Lakat2012-08-061-1/+1
| | | | | | | | | | | | | | | | Related to fixing bug 1031351 The testcase was meaningless. Change-Id: I7b88b86a600fac0c30bcac354262ac00593b495c
* | Add multiple-driver support to the notifier api.Andrew Bogott2012-08-021-15/+2
|/ | | | | | | | | | | Move all of the functionality previously provided by the list_notifier into the basic notifier api. Move and restructure tests accordingly. Remove the list_notifier file and test file. For bug 1025820 Change-Id: Idf7cb975dd78e9951188781622a4d10ca466b154
* Install a qualified except hook.Mate Lakat2012-08-011-0/+27
| | | | | | | | | | Fixes bug 1031351. As an Exception is raised, it was not visible in the log, because it wasn't qualified. The fix sets up the exception hook to be qualified as the product_name. Change-Id: Ie8061d003b05ea8b00db5d8ed8fa445ccc822942
* don't throw exceptions if %(color)s tag is usedSean Dague2012-07-271-0/+54
| | | | | | | | | | | | | | | fixed bug #1030078 If the log format strings include the %(color)s key in them and you enable file logging, your log files won't work, and instead you'll see exceptions on the console as the default python log handler doesn't support that keyword. This approach stubs out the extra keywords to be empty strings to avoid the KeyError. Tests are also added to demonstrate the KeyError as defined behavior, and test that color codes can be passed. Change-Id: Ia5dbaee9c530e243e2121667c8a54e6f9d66e1e7
* fix bug lp:1019348,update openstack-common to support pep8 1.3.Yaguang Tang2012-07-181-5/+5
| | | | | | also,this patch turns off pep8 E125 check. Change-Id: I22d2a94d89530586d614af39af17ae542c5e0cbf
* Switch common files to using jsonutils.Andrew Bogott2012-07-031-3/+3
| | | | | | | | For blueprint use-common-jsonutils Pretty much just a search and replace. Change-Id: I66f63e7b0ff82a37d8a6b9acef94f4e10a45bf90
* Add common logging and notification.Andrew Bogott2012-06-251-0/+218
This code is migrated from Nova, and will soon replace it. Change-Id: I2dacac3ef251d419c7049154f6aaf0c18fdb9bb4