Genesis Foundation Logger
foundation-logger
provides a logging utility that currently wraps version 2 of consola.
Installation
To enable this module in your application, follow the steps below.
- Add
@genesislcap/foundation-logger
as a dependency in your package.json
file. Whenever you change the dependencies of your project, ensure you run the $ npm run bootstrap
command again. You can find more information in the package.json basics page.
{
...
"dependencies": {
...
"@genesislcap/foundation-logger": "latest"
...
},
...
}
- Create a logger in my-package/utils/logger.ts for example.
import { createLogger } from '@genesislcap/foundation-logger';
export const logger = createLogger('my-package');
The logger will be set to LogLevel.Debug
by default, however you can pass options as the second parameter to tailor this.
export const logger = createLogger('my-package', { level: LogLevel.Debug, ... });
LoggerOptions
type extends the ConsolaOptions
type.
- Use the logger in your package.
import { logger } from '../utils';
...
logger.debug('Checks complete');
- Explicitly set the log level of an imported foundation package when needed.
import { logger as commsLogger } from '@genesislcap/foundation-comms';
import { logger as storeLogger } from '@genesislcap/foundation-store';
import { LogLevel } from '@genesislcap/foundation-logger';
commsLogger.level = LogLevel.Warn;
storeLogger.level = LogLevel.Silent;
License
Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact Genesis Global for more details.
Licensed components
Genesis low-code platform