Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logger-fp-ts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logger-fp-ts - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [0.2.0](https://github.com/thewilkybarkid/logger-fp-ts/compare/v0.1.2...v0.2.0) (2022-03-28)
### Features
* add payloads to log messages ([9f8e6c6](https://github.com/thewilkybarkid/logger-fp-ts/commit/9f8e6c688613b9e39884e266c581b05a2a76d6ab))
### [0.1.2](https://github.com/thewilkybarkid/logger-fp-ts/compare/v0.1.1...v0.1.2) (2022-03-23)

@@ -7,0 +14,0 @@

41

dist/index.d.ts
import { ClockEnv } from 'clock-ts';
import * as RIO from 'fp-ts-contrib/ReaderIO';
import * as E from 'fp-ts/Eq';
import * as Json from 'fp-ts/Json';
import * as S from 'fp-ts/Show';
import * as L from 'logging-ts/lib/IO';
import Eq = E.Eq;
import JsonRecord = Json.JsonRecord;
import LoggerIO = L.LoggerIO;

@@ -28,2 +30,3 @@ import ReaderIO = RIO.ReaderIO;

readonly level: LogLevel;
readonly payload: JsonRecord;
}

@@ -41,3 +44,3 @@ /**

*/
export declare const LogEntry: (message: string, date: Date, level: LogLevel) => LogEntry;
export declare const LogEntry: (message: string, date: Date, level: LogLevel, payload: JsonRecord) => LogEntry;
/**

@@ -83,3 +86,12 @@ * @example

/**
* Log a 'DEBUG' message with a payload.
*
* @category instances
* @since 0.2.0
*/
export declare const debugP: (message: string) => (payload: JsonRecord) => ReaderIO<LoggerEnv, void>;
/**
* Log a 'DEBUG' message.
*
* @category instances
* @since 0.1.0

@@ -89,3 +101,12 @@ */

/**
* Log an 'INFO' message with a payload.
*
* @category instances
* @since 0.2.0
*/
export declare const infoP: (message: string) => (payload: JsonRecord) => ReaderIO<LoggerEnv, void>;
/**
* Log an 'INFO' message.
*
* @category instances
* @since 0.1.0

@@ -95,3 +116,12 @@ */

/**
* Log a 'WARN' message with a payload.
*
* @category instances
* @since 0.2.0
*/
export declare const warnP: (message: string) => (payload: JsonRecord) => ReaderIO<LoggerEnv, void>;
/**
* Log a 'WARN' message.
*
* @category instances
* @since 0.1.0

@@ -101,5 +131,14 @@ */

/**
* Log an 'ERROR' message with a payload.
*
* @category instances
* @since 0.2.0
*/
export declare const errorP: (message: string) => (payload: JsonRecord) => ReaderIO<LoggerEnv, void>;
/**
* Log an 'ERROR' message.
*
* @category instances
* @since 0.1.0
*/
export declare const error: (message: string) => ReaderIO<LoggerEnv, void>;

@@ -29,3 +29,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.error = exports.warn = exports.info = exports.debug = exports.EqLogEntry = exports.getColoredShow = exports.ShowLogEntry = exports.match = exports.withShow = exports.LogEntry = void 0;
exports.error = exports.errorP = exports.warn = exports.warnP = exports.info = exports.infoP = exports.debug = exports.debugP = exports.EqLogEntry = exports.getColoredShow = exports.ShowLogEntry = exports.match = exports.withShow = exports.LogEntry = void 0;
/**

@@ -42,2 +42,3 @@ * @since 0.1.0

const L = __importStar(require("logging-ts/lib/IO"));
const safe_stable_stringify_1 = __importDefault(require("safe-stable-stringify"));
// -------------------------------------------------------------------------------------

@@ -50,6 +51,7 @@ // constructors

*/
const LogEntry = (message, date, level) => ({
const LogEntry = (message, date, level, payload) => ({
message,
date,
level,
payload,
});

@@ -85,8 +87,9 @@ exports.LogEntry = LogEntry;

const log = entry => ({ logger }) => logger(entry);
const logEntryForDate = (message, level) => date => ({
const logEntryForDate = (message, level, payload) => date => ({
message,
date,
level,
payload,
});
const logAtLevel = level => message => (0, function_1.pipe)(clock_ts_1.now, RIO.map(logEntryForDate(message, level)), RIO.chain(log));
const logAtLevel = level => message => payload => (0, function_1.pipe)(clock_ts_1.now, RIO.map(logEntryForDate(message, level, payload)), RIO.chain(log));
// -------------------------------------------------------------------------------------

@@ -100,3 +103,3 @@ // instances

exports.ShowLogEntry = {
show: ({ message, date, level }) => `${date.toISOString()} | ${level} | ${message}`,
show: ({ message, date, level, payload }) => `${date.toISOString()} | ${level} | ${message}${Object.keys(payload).length > 0 ? ` | ${(0, safe_stable_stringify_1.default)(payload)}` : ''}`,
};

@@ -126,22 +129,59 @@ /**

level: s.Eq,
payload: (0, function_1.pipe)(s.Eq, E.contramap(safe_stable_stringify_1.default)),
});
/**
* Log a 'DEBUG' message with a payload.
*
* @category instances
* @since 0.2.0
*/
exports.debugP = logAtLevel('DEBUG');
/**
* Log a 'DEBUG' message.
*
* @category instances
* @since 0.1.0
*/
exports.debug = logAtLevel('DEBUG');
exports.debug = (0, function_1.flow)(exports.debugP, (0, function_1.apply)({}));
/**
* Log an 'INFO' message with a payload.
*
* @category instances
* @since 0.2.0
*/
exports.infoP = logAtLevel('INFO');
/**
* Log an 'INFO' message.
*
* @category instances
* @since 0.1.0
*/
exports.info = logAtLevel('INFO');
exports.info = (0, function_1.flow)(exports.infoP, (0, function_1.apply)({}));
/**
* Log a 'WARN' message with a payload.
*
* @category instances
* @since 0.2.0
*/
exports.warnP = logAtLevel('WARN');
/**
* Log a 'WARN' message.
*
* @category instances
* @since 0.1.0
*/
exports.warn = logAtLevel('WARN');
exports.warn = (0, function_1.flow)(exports.warnP, (0, function_1.apply)({}));
/**
* Log an 'ERROR' message with a payload.
*
* @category instances
* @since 0.2.0
*/
exports.errorP = logAtLevel('ERROR');
/**
* Log an 'ERROR' message.
*
* @category instances
* @since 0.1.0
*/
exports.error = logAtLevel('ERROR');
exports.error = (0, function_1.flow)(exports.errorP, (0, function_1.apply)({}));

6

package.json
{
"name": "logger-fp-ts",
"description": "A logger for use with fp-ts.",
"version": "0.1.2",
"version": "0.2.0",
"license": "MIT",

@@ -13,3 +13,4 @@ "homepage": "https://github.com/thewilkybarkid/logger-fp-ts",

"dependencies": {
"chalk": "^4.1.2"
"chalk": "^4.1.2",
"safe-stable-stringify": "^2.3.1"
},

@@ -38,2 +39,3 @@ "peerDependencies": {

"prettier-plugin-sh": "^0.8.1",
"sortobject": "^4.16.0",
"standard-version": "^9.3.2",

@@ -40,0 +42,0 @@ "ts-jest": "^27.1.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc