-
Notifications
You must be signed in to change notification settings - Fork 19
Description
The documentation for running anylogger assumes anylogger as bundled package where it is directly loaded in the browser and globally available. The problem looks to be that ulog is not actually bundled because the only reference to ulog as the implementation is an import. Bundlers will treeshake the package.
Expected
Add logging to a project and logging messages will be written to the console in the browser
Actual
Nothing appears inn the browser console.
Steps to reproduce
Created a brand new Vue project and add logging
- vue create logger-demo
- yarn install anylogger ulog
- add the logging code into main.js
- yarn serve
- load up the browser, dev tools and look at messages
Based on the sample README, only a reference to anylogger is required.
import anylogger from 'anylogger';
const log = anylogger('Logging');
log.debug('I will not log unless log level is reduced');
log.error('I should log even in default settings');
// result nothing logsAdd ulog import, still doesn't work (under my build system-let's assume "tree shaking" broadly)
import anylogger from 'anylogger';
import ulog from 'ulog';
const log = anylogger('Logging');
log.debug('I will not log unless log level is reduced');
log.error('I should log even in default settings');
// result still nothing logs (as ulog still isn't there)Of course, the logging library is actually required to implement the interface. Without typings, it all gets hard and picked something random to log that ensures the library is bundled.
import anylogger from 'anylogger';
import ulog from 'ulog';
const log = anylogger('Logging');
// need a reference to include library and ensure no linting errors
log.debug(ulog.levels); // ah, need typings so added `declare module 'ulog'` (or could use `ulog.d.ts`)
log.debug('I will not log unless log level is reduced');
log.error('I should log even in default settings');
// now I log