swork-logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

swork-logger

swork-logger is a swork middleware designed to log info for every fetch request made through the service worker. It is built with TypeScript and async methods.

License

MIT

Installation

npm install swork-logger

yarn add swork-logger

Example

import { Swork } from "swork";
import { logger } from "swork-logger";
 
const app = new Swork();
 
app.use(logger());
 
app.listen();

Notes

It is suggested to include logger early in the request pipeline to be able to log all fetch requests. The default message will provide contextual information regarding each request including the http method, url, status and execution time. In addition, each log entry is color coded based upon the status.

If desired, the logging implementation can be overridden:

 
class CustomLogger implements IFetchLogger {
    public log(data: FetchData) { ... }
}
 
app.use(logger(new CustomLogger()));

Contact

If you are using swork or any of its related middlewares, please let me know on gitter. I am always looking for feedback or additional middleware ideas.

Dependents (1)

Package Sidebar

Install

npm i swork-logger

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

9.53 kB

Total Files

9

Last publish

Collaborators

  • justin-arch-sw