@sbc-fe/x.jslogger
v1.0.3
Published
jslogger
Downloads
41
Readme
x.jslogger.js 前端日志记录
Web
<script src="../lib/x.jslogger.js"></script>
<script>
var xconsole = jsLogger;
// console.log(xconsole);
xconsole.adapter = function(data, query) {
console.log('>>> jsLogger report query -----------');
console.log(data, '\n', query);
console.log('\n\n');
var img = new Image();
img.src = 'http://test.com/xlog?'+query;
}
// xconsole.config({log: 1});
// xconsole.set({siteCode: 123});
xconsole.log('x1', {'x2': true}, 'x3');
xconsole.error('errorasdfasdf');
</script>
Vue
// main.js
import Vue from 'vue';
import jsLogger from '@sbc-fe/x.jslogger';
// jsLogger.config({log: 1});
// jsLogger.set({siteCode: 123});
jsLogger.adapter = function(data, query) {
var img = new Image();
img.src = 'http://test.com/xlog?'+query;
}
Vue.prototype.$console = jsLogger;
// component
// console.log(this.$xconsole);
this.$xconsole.log('x1', {'x2': true}, 'x3');
this.$xconsole.error('errorasdfasdf');
uni-app
// main.js
import jsLogger from '@sbc-fe/x.jslogger';
// jsLogger.config({log: 1});
// jsLogger.set({siteCode: 123});
jsLogger.adapter = function(data, query) {
url = url && url.indexOf('?') < 0 ? url+'?' : url;
var img = new Image();
img.src = 'http://test.com/xlog?'+query;
// or
//uni.request(...);
}
uni.$console = jsLogger;
uni.$xconsole.log('x1', {'x2': true}, 'x3');
uni.$xconsole.error('errorasdfasdf');