-
Notifications
You must be signed in to change notification settings - Fork 8
Exercise 3: context
Kevin Schuchard edited this page Apr 30, 2019
·
10 revisions
- Define a new constant variable named
loggerthat is a reference to theSchematicContext.loggerinstance. - Use the
logger.debug()method - Use the
logger.info()method - Use the
logger.warn()method - Use the
logger.error()method
For example:
export function schematicStarter(_options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
const logger = _context.logger;
logger.debug('This is a debug message');
return tree;
};
}npm run buildschematics .:hello-world --dry-run=falseYou should see the info, warn, and error messages print out.
- Execute the
schematicscommand by itself for a list of additional options - Did the
debuglogger not print out? Run the schematic with with the verbose flag
schematics .:hello-world --dry-run=false --verbose