1.1.0 • Published 9 months ago

with-logger v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

with-logger

npm Version Total Downloads Workflow status

Installation

npmjs.com/package/with-logger

# yarn
$ yarn add with-logger

# npm
$ npm install with-logger

Usage

Use it like console:

import { logger } from "with-logger";

const metadata = { 
    userId: "2e01d247-1dc1-4d39-a287-f8a069544d43",
    location: "San Francisco, CA"
};

logger.info("👋 Hello World");
// 2021-01-01 12:34:56.416 info : 👋 Hello World

logger.debug("User metadata", metadata);
// 2021-01-01 12:34:56.416 debug : User metadata {
//   userId: "2e01d247-1dc1-4d39-a287-f8a069544d43",
//   location: "San Francisco, CA"
// }

logger.with({ userId: metadata.userId  }).info("User changed location to", newLocation);
// 2021-01-01 12:34:56.416 info [userId=2e01d247-1dc1-4d39-a287-f8a069544d43] : User changed location to Menlo Park, CA

logger.with({ ...metadata }).warn("Failed to sync user location");
// 2021-01-01 12:34:56.416 info [userId=2e01d247-1dc1-4d39-a287-f8a069544d43] [location=San Francisco, CA] : Failed to sync user location

try {
    perform();
} catch (error) {
    logger.with({ ...session }).error(error);
}
// 2021-01-01 12:34:56.416 error [id=6033bda3-1a63-44a9-97f1-e15e097c98c0] : Unable to reach server

August 2021 - Toronto

1.1.0

9 months ago

1.0.9

1 year ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago