smyld-lib-common
Version:
SMYLD Javascript Core Library, contains several core APIs that benefit the developers working on SPA applications
65 lines (64 loc) • 1.78 kB
TypeScript
import { LogSettings } from './logging/LogSettings';
import { Logger } from './index';
import { App } from 'vue';
/**
* Vue plugin for integrating the Logger functionality into Vue applications.
* Provides a $log property on all Vue components and makes the logger available through dependency injection.
*
* @example
* // In your main.js or main.ts file:
* import { createApp } from 'vue';
* import App from './App.vue';
* import { VueLoggerPlugin } from 'smyld-lib-common';
*
* const app = createApp(App);
*
* // Use the plugin with default settings
* app.use(VueLoggerPlugin);
*
* // Or with custom settings
* app.use(VueLoggerPlugin, {
* logLevel: LogLevel.DEBUG,
* cacheLogs: true
* });
*
* app.mount('#app');
*
* @example
* // In a Vue component:
* export default {
* mounted() {
* this.$log.info('Component mounted');
* },
* methods: {
* handleClick() {
* this.$log.debug('Button clicked', { timestamp: Date.now() });
* }
* }
* }
*/
export declare const VueLoggerPlugin: {
/**
* Vue 3 plugin installation method.
*
* @param {App} app - The Vue application instance
* @param {LogSettings} [options] - Optional logger configuration
*/
install: (app: App, options?: LogSettings) => void;
};
/**
* Type declaration to extend Vue's ComponentCustomProperties interface
* This makes the $log property available on all Vue components with proper typing
*/
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
/**
* Logger instance available on all Vue components.
* Use this to log messages from your components.
*
* @example
* this.$log.info('User logged in');
*/
$log: Logger;
}
}