Building Reusable Angular Services: Logging
Learn how to perform logging in Angular applications by creating a set of reusable log publishing classes. A log publishers service replaces console.log() making your logging much more flexible.
What you'll learn
Professional programmers know that logging errors and being able to track what is going on within an Angular application is essential. In this course, Building Reusable Angular Services: Logging, you'll learn how to design an Angular service to perform logging more efficiently and with more flexibility than just using console.log(), by creating an extensible Angular service to log any data to a variety of locations. First, you'll explore how to build a simple console logging class, a class to log to local storage, and a class to post log information to a Web API. Additionally, you'll delve into building different types of log entries, such as debug, informational, error, and warnings. Finally, you'll discover how to create a JSON configuration file to control where you log the data. By the end of this course, you'll have a great start on your logging service that can be used in your own applications. This service can replace all your console.log() calls to provide a better, and more flexible approach to logging.
Table of contents
- Module Introduction 1m
- Create LogEntry Class and Properties 2m
- Write the buildLogString() and formatParms() Methods 2m
- Rewrite writeToLog() Method to Use LogEntry Class 2m
- Create LogPublisher Base Class 3m
- Create LogConsole Class to Log Data to Console 2m
- Create LogPublishersService Class 4m
- Modify LogService Class to Use the Log Publishers Service 4m
- Module Summary 1m
- Module Introduction 1m
- Create the Structure of the LogLocalStorage Class 3m
- Create the log() and clear() Methods 2m
- Add LogLocalStorage to Publishers Array and Test 3m
- Add clear() Method to LogService and Test 2m
- Log a Product Object Using Your Log Service 3m
- Create getAll() Method in LogLocalStorage Class 2m
- Test Retrieving All Values from Local Storage 4m
- Module Summary 1m
- Module Introduction 1m
- Create Web API Project, LogLevel Enum, and LogEntry Class 3m
- Build the LogController Class 2m
- Enable CORS in the Web API Project 3m
- Start Creating the LogWebApi Publisher 3m
- Create Constructor and log() Method 2m
- Build the clear() and handleErrors() Methods 3m
- Add LogWebApi to Log Publishers Service 2m
- Test and See the Call to the Web API 1m
- Module Summary 1m
- Module Introduction 1m
- Build the JSON Configuration File 3m
- Create LogPublisherConfig Class 1m
- Add Import Statements in Log Publishers Service Class 1m
- Add handleErrors() Method 1m
- Add getLoggers() Method 1m
- Read All Publishers from JSON File 4m
- Run and Test Reading the Publishers 2m
- Module and Course Summary 1m