[英]How to persist javascript console.log in REST Web Services (by overloads)?
I have a Angular 5 application with any javascript console.log("...");
我有一个带有任何 javascript
console.log("...");
的 Angular 5 应用程序console.log("...");
I want create and add a javascript file on top on my application that overloads all console.log("...");
我想在我的应用程序的顶部创建并添加一个 javascript 文件,该文件重载所有
console.log("...");
with a POST function to a Web Services.具有 POST 功能到 Web 服务。
If my classic application log this:如果我的经典应用程序记录这个:
console.log("start");
console.log("error");
console.log("stop");
I want my Angular5 application to process 3 asynchone POST requests to my Web Services.我希望我的 Angular5 应用程序处理 3 个对我的 Web 服务的异步 POST 请求。 Example:
例子:
POST {"user": "foo", "log": "start"}
POST {"user": "foo", "log": "error"}
POST {"user": "foo", "log": "stop"}
Note: The user in the body is just an example because the final version uses a Json Web Token in the header.注意:正文中的用户只是一个示例,因为最终版本在标题中使用了 Json Web Token。
Is there a library to do this because it seems like a basic feature?是否有图书馆可以做到这一点,因为它似乎是一个基本功能?
How about replacing the default log function.如何替换默认的日志功能。
(function() { var oldLog = console.log; console.log = function(msg) { oldLog.apply(console, arguments); alert(msg); } })() console.log("test")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.