https://github.com/jweyrich/tslogger
[POC] A simple TypeScript library to handle logging
https://github.com/jweyrich/tslogger
cloudwatch-logs log logger logging logging-library typescript
Last synced: 8 months ago
JSON representation
[POC] A simple TypeScript library to handle logging
- Host: GitHub
- URL: https://github.com/jweyrich/tslogger
- Owner: jweyrich
- License: isc
- Created: 2020-09-21T01:03:14.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-25T19:16:43.000Z (about 5 years ago)
- Last Synced: 2025-01-05T20:40:55.201Z (9 months ago)
- Topics: cloudwatch-logs, log, logger, logging, logging-library, typescript
- Language: TypeScript
- Homepage:
- Size: 97.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### TsLogger (NOT READY TO USE YET!)
A simple TypeScript library to handle logging.
#### How to install
```
npm install https://github.com/jweyrich/tslogger#master
```#### How to use
```
import { TsLogger } from 'tslogger';
const logger = new TsLogger({ format: LogFormat.text, minLevel: LogLevel.TRACE });
logger.trace("message using the trace level");
logger.debug("message using the debug level");
const someContext = {
strProperty: "value",
boolProperty: false,
numberProperty: 3.1415,
nullProperty: null as string,
requestId: "4f732a3d-d136-48d7-ae32-f5895a739413",
};
logger.info("message using the info level", someContext);
logger.warn("message using the warn level");
logger.error("message using the error level", null, new Error("recoverable error"));
logger.fatal("message using the fatal level", null, new Error("fatal error"));
try {
throw new RangeError('index out of bounds');
} catch (e) {
logger.fatal("caught a fatal exception", null, e);
}
```