SimpleX2-SDK-Util-Console is a utility library for console manipulation in SimpleX2 SDK.
- Create a new console object
npm install @simplex2-sdk-util/console
// console.js
import Console from '@simplex2-sdk-util/console'
// Create a new console object whitout SimpleX2 plugin creator
const console = new Console()
// console.js
import Console from '@simplex2-sdk-util/console'
import pluginsManager from '@simplex2-sdk-util/plugins-manager'
pluginsManager.addVuePlugin('console', {
hangInWindow: true,
install: true,
hangInWindowName: 'simplex2UtilSDKConsole',
hangInVueName: '$consoleSDK',
plugin: (that, Vue, options) => {
return new Console(options)
}
})
// in Vue2 main.js
import Vue from 'vue'
import App from './App.vue'
import console from './console'
Vue.use(console)
new Vue({
render: h => h(App)
}).$mount('#app')
// end Vue2 main.js
/* --- or --- */
// in Vue3 main.js
import { createApp } from 'vue'
import App from './App.vue'
import console from './console'
const app = createApp(App)
app.use(console)
app.mount('#app')
// end Vue3 main.js
options = {
level: 'info', // default level this is the default level of the console => log < info < warn < error
allowLevel: ['log', 'info', 'warn', 'error'], // default allowLevel
coverConsoleMethods: true, // default coverConsoleMethods if true, window.console object will be covered
logDate: true, // default logDate if true, the date will be logged
logTime: true, // default logTime if true, the time will be logged
dateFormatter: 'YYYY-MM-DD', // default dateFormatter
timeFormatter: 'HH:mm:ss', // default timeFormatter
upload: false, // default upload if true, the console will be use uploadMethod
uploadMethod: () => {
}, // default uploadMethod you can use this method to upload the console to the server
switchConsole: true // default switchConsole
}
console.log('Hello World!')
console.info('Hello World!')
console.warn('Hello World!')
console.error('Hello World!')
console.open()
console.close()
console.getConsoleState()
// return
// true