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

@compas/insight

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compas/insight - npm Package Compare versions

Comparing version 0.0.114 to 0.0.115

4

package.json
{
"name": "@compas/insight",
"version": "0.0.114",
"version": "0.0.115",
"description": "Simple logger in NDJSON format",

@@ -35,3 +35,3 @@ "main": "./index.js",

},
"gitHead": "8b812302ca94a104e8329f8f6c6158d1ab793e6c"
"gitHead": "2bb525228f13305555f6dfd8de6d6e07013f149c"
}
import { newLogger } from "@compas/insight";
/**
* Create a new event from a single logger
* Create a new event from a logger
*
* @since 0.1.0
*
* @param {Logger} logger Logger should have a context, like the default `ctx.log`

@@ -21,2 +23,4 @@ * @returns {Event}

*
* @since 0.1.0
*
* @param {Event} event

@@ -39,4 +43,7 @@ * @returns {Event}

*
* @since 0.1.0
*
* @param {Event} event
* @param {string} name
* @returns {void}
*/

@@ -56,4 +63,7 @@ export function eventStart(event, name) {

*
* @since 0.1.0
*
* @param {Event} event
* @param {string} name
* @returns {void}
*/

@@ -68,3 +78,6 @@ export function eventRename(event, name) {

*
* @since 0.1.0
*
* @param {Event} event
* @returns {void}
*/

@@ -88,4 +101,7 @@ export function eventStop(event) {

* Create a new test event
*
* @since 0.1.0
*
* @param {{ enableLogs?: boolean }} [options={}]
* @return {Event}
* @returns {Event}
*/

@@ -92,0 +108,0 @@ export function newTestEvent(options = {}) {

@@ -6,2 +6,6 @@ import { writeNDJSON, writePretty } from "./writer.js";

/**
* Create a new logger instance
*
* @since 0.1.0
*
* @param {LoggerOptions} [options]

@@ -43,2 +47,5 @@ * @returns {Logger}

* Wrap provided writer function to be used in the Logger
*
* @param {function} fn
* @returns {function}
*/

@@ -45,0 +52,0 @@ function wrapWriter(fn) {

import { inspect } from "util";
/**
* @param stream
* @param level
* @param timestamp
* @param context
* @param message
* @param {NodeJS.WritableStream} stream
* @param {string} level
* @param {Date} timestamp
* @param {string} context
* @param {*} message
* @returns {void}
*/

@@ -19,7 +20,8 @@ export function writeNDJSON(stream, level, timestamp, context, message) {

/**
* @param stream
* @param level
* @param timestamp
* @param context
* @param message
* @param {NodeJS.WritableStream} stream
* @param {string} level
* @param {Date} timestamp
* @param {string} context
* @param {*} message
* @returns {void}
*/

@@ -26,0 +28,0 @@ export function writePretty(stream, level, timestamp, context, message) {

const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB"];
/**
* Convert bytes to a human readable value
*
* @since 0.1.0
*
* @param {number} [bytes]

@@ -27,3 +31,8 @@ * @returns {string}

/**
* Print memory usage of this Node.js process
*
* @since 0.1.0
*
* @param {Logger} logger
* @returns {void}
*/

@@ -30,0 +39,0 @@ export function printProcessMemoryUsage(logger) {

@@ -6,2 +6,5 @@ /**

*
* @since 0.1.0
* @summary Get the estimated disk size and row count for all tables
*
* @param {Postgres} sql

@@ -12,11 +15,12 @@ * @returns {Promise<Object<string, { diskSize: number, rowCount: number }>>}

const queryResult = await sql`
SELECT relname AS "relation",
pg_total_relation_size(c.oid) AS "diskSize",
c.reltuples as "rowCount"
FROM pg_class c
LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND c.relkind = ANY (ARRAY ['r', 'v', 'm'])
AND nspname !~ '^pg_toast'
`;
SELECT relname AS "relation",
pg_total_relation_size(c.oid) AS "diskSize",
c.reltuples AS "rowCount"
FROM pg_class c
LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
WHERE
nspname NOT IN ('pg_catalog', 'information_schema')
AND c.relkind = ANY (ARRAY ['r', 'v', 'm'])
AND nspname !~ '^pg_toast'
`;

@@ -23,0 +27,0 @@ const result = {};

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