mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Add Dark Mode option into logger
This commit is contained in:
parent
caf4f56b10
commit
0c68c515df
2 changed files with 18 additions and 3 deletions
|
@ -11,11 +11,13 @@ export default class VueSocketIO {
|
||||||
* @param io
|
* @param io
|
||||||
* @param vuex
|
* @param vuex
|
||||||
* @param debug
|
* @param debug
|
||||||
|
* @param darkMode
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
constructor({connection, vuex, debug, options}){
|
constructor({connection, vuex, debug, darkMode, options}){
|
||||||
|
|
||||||
Logger.debug = debug;
|
Logger.debug = debug;
|
||||||
|
Logger.darkMode = darkMode;
|
||||||
this.io = this.connect(connection, options);
|
this.io = this.connect(connection, options);
|
||||||
this.useConnectionNamespace = (options && options.useConnectionNamespace);
|
this.useConnectionNamespace = (options && options.useConnectionNamespace);
|
||||||
this.namespaceName = (options && options.namespaceName);
|
this.namespaceName = (options && options.namespaceName);
|
||||||
|
|
|
@ -4,13 +4,20 @@
|
||||||
export default new class VueSocketIOLogger {
|
export default new class VueSocketIOLogger {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
this.darkMode = false;
|
||||||
this.debug = false;
|
this.debug = false;
|
||||||
this.prefix = '%cVue-Socket.io: ';
|
this.prefix = '%cVue-Socket.io: ';
|
||||||
}
|
}
|
||||||
|
|
||||||
info(text, data = '') {
|
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 = ''){
|
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…
Add table
Reference in a new issue