You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kevin Schuchard edited this page Apr 30, 2019
·
10 revisions
Use SchematicContext.logger
Define a new constant variable named logger that is a reference to the SchematicContext.logger instance.
Use the logger.debug() method
Use the logger.info() method
Use the logger.warn() method
Use the logger.error() method
For example:
exportfunctionschematicStarter(_options: any): Rule{return(tree: Tree,_context: SchematicContext)=>{constlogger=_context.logger;logger.debug('This is a debug message');returntree;};}
Build the project
npm run build
Execute the hello-world schematic using the CLI
schematics .:hello-world --dry-run=false
You should see the info, warn, and error messages print out.
Bonus
Execute the schematics command by itself for a list of additional options
Did the debug logger not print out? Run the schematic with with the verbose flag