# p-log **Repository Path**: mirrors_sindresorhus/p-log ## Basic Information - **Project Name**: p-log - **Description**: Log the value/error of a promise - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-19 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # p-log > Log the value/error of a promise ## Install ``` $ npm install p-log ``` ## Usage ```js import pLog from 'p-log'; Promise.resolve('unicorn') .then(pLog()) // Logs `unicorn` .then(value => { // `value` is still `unicorn` }); ``` ```js import pLog from 'p-log'; Promise.resolve() .then(() => { throw new Error('pony'); }) .catch(pLog.catch()) // Logs `Error: pony` .catch(error => { // `error` is still `Error: pony` }); ``` ## API ### pLog(logger?) Use this in a `.then()` method. Returns a [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`. ### pLog.catch(logger?) Use this in a `.catch()` method. Returns a [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`. #### logger Type: `Function`\ Default: `console.log` The logger to use. Any return value or exception is ignored. ## Related - [p-tap](https://github.com/sindresorhus/p-tap) - Tap into a promise chain without affecting its value or state - [p-if](https://github.com/sindresorhus/p-if) - Conditional promise chains - [p-catch-if](https://github.com/sindresorhus/p-catch-if) - Conditional promise catch handler - [More…](https://github.com/sindresorhus/promise-fun)