1.

How can you maintain logs in AngularJS?

Answer»

Logs in AngularJS can be maintained by using the $log built-in service. These are mainly used for TROUBLESHOOTING and debugging in case of any unexpected scenarios. They are done by mainly using the below methods:

  1. log(): To log a message onto the console. Example usage: $log.log(‘Entered some function’)
  2. INFO(): To write any message which represents information. Example usage: $log.info(‘Data PROCESSED successfully’)
  3. warn(): To log warnings. Example usage: $log.warn(‘The value is empty.’)
  4. error(): To log errors. Example usage: $log.error(‘OH no! Something WENT wrong.’)
  5. debug(): To log any debug messages useful for debugging. Example usage: $log.debug(‘Processed a variable A.’)


Discussion

No Comment Found