Add Dark Mode option into logger

pull/231/head
Phantas Weng 5 years ago
parent caf4f56b10
commit 0c68c515df

@ -11,11 +11,13 @@ export default class VueSocketIO {
* @param io
* @param vuex
* @param debug
* @param darkMode
* @param options
*/
constructor({connection, vuex, debug, options}){
constructor({connection, vuex, debug, darkMode, options}){
Logger.debug = debug;
Logger.darkMode = darkMode;
this.io = this.connect(connection, options);
this.useConnectionNamespace = (options && options.useConnectionNamespace);
this.namespaceName = (options && options.namespaceName);

@ -4,13 +4,20 @@
export default new class VueSocketIOLogger {
constructor() {
this.darkMode = false;
this.debug = false;
this.prefix = '%cVue-Socket.io: ';
}
info(text, data = '') {
if(this.debug) window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
if(this.debug) {
if (this.darkMode) {
window.console.info(this.prefix+`%c${text}`, 'color: #A9D341; font-weight: 600', 'color: #F7AC15', data);
} else {
window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
}
}
}
@ -28,7 +35,13 @@ export default new class VueSocketIOLogger {
event(text, data = ''){
if(this.debug) window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
if(this.debug) {
if (this.darkMode) {
window.console.info(this.prefix+`%c${text}`, 'color: #A9D341; font-weight: 600', 'color: #F7AC15', data);
} else {
window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
}
}
}

Loading…
Cancel
Save