Logging: redirects for backwards compatibility
This commit is contained in:
1 parent
de253e5086
commit
77aeb6146e
3 files changed
+28
-4
No files matched your search
@@ -44,17 +44,17 @@
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.list = function(opts) {
|
||||
log.warn("OctoPrintClient.logs.list has been deprecated, use OctoPrintClient.plugins.logging.listLogs instead");
|
||||
log.warn("OctoPrintClient.logs.list has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.listLogs instead");
|
||||
return this.wrapped.listLogs(opts);
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.delete = function(file, opts) {
|
||||
log.warn("OctoPrintClient.logs.delete has been deprecated, use OctoPrintClient.plugins.logging.deleteLog instead");
|
||||
log.warn("OctoPrintClient.logs.delete has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.deleteLog instead");
|
||||
return this.wrapped.deleteLog(file, opts);
|
||||
};
|
||||
|
||||
DeprecatedOctoPrintLogsClient.prototype.download = function(file, opts) {
|
||||
log.warn("OctoPrintClient.logs.download has been deprecated, use OctoPrintClient.plugins.logging.downloadLog instead");
|
||||
log.warn("OctoPrintClient.logs.download has been deprecated as of OctoPrint 1.3.7, use OctoPrintClient.plugins.logging.downloadLog instead");
|
||||
return this.wrapped.downloadLog(file, opts);
|
||||
};
|
||||
|
||||
|
||||
@@ -527,7 +527,11 @@ class Server(object):
|
||||
# online indicators - text file with "online" as content and a transparent gif
|
||||
(r"/online.txt", util.tornado.StaticDataHandler, dict(data="online\n")),
|
||||
(r"/online.gif", util.tornado.StaticDataHandler, dict(data=bytes(base64.b64decode("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")),
|
||||
content_type="image/gif"))
|
||||
content_type="image/gif")),
|
||||
|
||||
# deprecated endpoints
|
||||
(r"/api/logs", util.tornado.DeprecatedEndpointHandler, dict(url="/plugin/logging/logs")),
|
||||
(r"/api/logs/(.*)", util.tornado.DeprecatedEndpointHandler, dict(url="/plugin/logging/logs/{0}")),
|
||||
]
|
||||
|
||||
# fetch additional routes from plugins
|
||||
|
||||
@@ -1075,6 +1075,26 @@ class StaticDataHandler(RequestlessExceptionLoggingMixin, tornado.web.RequestHan
|
||||
self.finish()
|
||||
|
||||
|
||||
class DeprecatedEndpointHandler(tornado.web.RequestHandler):
|
||||
def initialize(self, url):
|
||||
self._url = url
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
def _handle_method(self, *args, **kwargs):
|
||||
to_url = self._url.format(*args)
|
||||
self._logger.info("Redirecting deprecated endpoint {} to {}".format(self.request.path, to_url))
|
||||
self.redirect(to_url, permanent=True)
|
||||
|
||||
# make all http methods trigger _handle_method
|
||||
get = _handle_method
|
||||
post = _handle_method
|
||||
put = _handle_method
|
||||
patch = _handle_method
|
||||
delete = _handle_method
|
||||
head = _handle_method
|
||||
options = _handle_method
|
||||
|
||||
|
||||
class GlobalHeaderTransform(tornado.web.OutputTransform):
|
||||
|
||||
HEADERS = dict()
|
||||
|
||||
Reference in new issue
Block a user