| 96 | | def startKeepingErrors(): |
| 97 | | """ |
| 98 | | DEPRECATED in Twisted 2.5. |
| 99 | | |
| 100 | | Support function for testing frameworks. |
| 101 | | |
| 102 | | Start keeping errors in a buffer which can be retrieved (and emptied) with |
| 103 | | flushErrors. |
| 104 | | """ |
| 105 | | warnings.warn("log.startKeepingErrors is deprecated since Twisted 2.5", |
| 106 | | category=DeprecationWarning, stacklevel=2) |
| 107 | | global _keepErrors |
| 108 | | _keepErrors = 1 |
| 109 | | |
| 110 | | |
| 111 | | def flushErrors(*errorTypes): |
| 112 | | """ |
| 113 | | DEPRECATED in Twisted 2.5. See L{TestCase.flushLoggedErrors}. |
| 114 | | |
| 115 | | Support function for testing frameworks. |
| 116 | | |
| 117 | | Return a list of errors that occurred since the last call to flushErrors(). |
| 118 | | (This will return None unless startKeepingErrors has been called.) |
| 119 | | """ |
| 120 | | |
| 121 | | warnings.warn("log.flushErrors is deprecated since Twisted 2.5. " |
| 122 | | "If you need to flush errors from within a unittest, " |
| 123 | | "use TestCase.flushLoggedErrors instead.", |
| 124 | | category=DeprecationWarning, stacklevel=2) |
| 125 | | return _flushErrors(*errorTypes) |
| 126 | | |
| 127 | | |
| 128 | | def _flushErrors(*errorTypes): |
| 129 | | """ |
| 130 | | PRIVATE. DEPRECATED. DON'T USE. |
| 131 | | """ |
| 132 | | global _keptErrors |
| 133 | | k = _keptErrors |
| 134 | | _keptErrors = [] |
| 135 | | if errorTypes: |
| 136 | | for erk in k: |
| 137 | | shouldReLog = 1 |
| 138 | | for errT in errorTypes: |
| 139 | | if erk.check(errT): |
| 140 | | shouldReLog = 0 |
| 141 | | if shouldReLog: |
| 142 | | err(erk) |
| 143 | | return k |
| 144 | | |
| 145 | | def ignoreErrors(*types): |
| 146 | | """ |
| 147 | | DEPRECATED |
| 148 | | """ |
| 149 | | warnings.warn("log.ignoreErrors is deprecated since Twisted 2.5", |
| 150 | | category=DeprecationWarning, stacklevel=2) |
| 151 | | _ignore(*types) |
| 152 | | |
| 153 | | def _ignore(*types): |
| 154 | | """ |
| 155 | | PRIVATE. DEPRECATED. DON'T USE. |
| 156 | | """ |
| 157 | | for type in types: |
| 158 | | _ignoreErrors.append(type) |
| 159 | | |
| 160 | | def clearIgnores(): |
| 161 | | """ |
| 162 | | DEPRECATED |
| 163 | | """ |
| 164 | | warnings.warn("log.clearIgnores is deprecated since Twisted 2.5", |
| 165 | | category=DeprecationWarning, stacklevel=2) |
| 166 | | _clearIgnores() |
| 167 | | |
| 168 | | def _clearIgnores(): |
| 169 | | """ |
| 170 | | PRIVATE. DEPRECATED. DON'T USE. |
| 171 | | """ |
| 172 | | global _ignoreErrors |
| 173 | | _ignoreErrors = [] |
| 174 | | |