{"id":15491527,"url":"https://github.com/tcodes0/console-helpers","last_synced_at":"2026-02-22T21:47:14.978Z","repository":{"id":40795479,"uuid":"225735639","full_name":"tcodes0/console-helpers","owner":"tcodes0","description":"Useful helpers for console logging things","archived":false,"fork":false,"pushed_at":"2023-01-06T02:19:28.000Z","size":1574,"stargazers_count":4,"open_issues_count":13,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-20T07:40:48.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcodes0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-03T23:16:31.000Z","updated_at":"2020-07-21T13:13:12.000Z","dependencies_parsed_at":"2023-02-05T02:45:50.439Z","dependency_job_id":null,"html_url":"https://github.com/tcodes0/console-helpers","commit_stats":null,"previous_names":["thomazella/console-helpers"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tcodes0/console-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcodes0%2Fconsole-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcodes0%2Fconsole-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcodes0%2Fconsole-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcodes0%2Fconsole-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcodes0","download_url":"https://codeload.github.com/tcodes0/console-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcodes0%2Fconsole-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29728503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T07:54:09.887Z","updated_at":"2026-02-22T21:47:14.928Z","avatar_url":"https://github.com/tcodes0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Console helpers\n\n`console.log` helpers\n\n## Basically...\n\nThis lib exports some helpers you can either import and use directly or add to `console` (the global guy)\n\n-   if adding to `global.console`, call `addToGlobalConsole` in a file close to your entry point (like `index.js`)\n-   uses [util.inspect](https://nodejs.org/api/util.html#util_util_inspect_object_options). Highly recommended to read the docs to understand the options\n-   lib also exports a few functions to set options for logging\n\n# Usage\n\n## `logs: (...args: any[]) =\u003e void`\n\n`log string`\n\n\n-   nested object that you want to log\n-   want to make console.log easier to read\n\n```typescript\nimport { logs } from 'console-helpers'\n\nlogs({ foo: { bar: { baz: 22 } } })\n```\n\n```text\n  // console log output\n\n  console.logs {\n    foo: {\n      bar: {\n        baz: 22\n      }\n    }\n  }\n```\n\nuses [util.inspect](https://nodejs.org/api/util.html#util_util_inspect_object_options)\n\n## `logk: (...args: any[]) =\u003e void`\n\n`log keys`\n\n\n-   big object that you want to understand what's inside\n-   complex props with several hocs\n-   props with data from server, but the internals of the data are not so important\n\n```typescript\nimport { logk } from 'console-helpers'\n\nlogk({ foo: 22, bar: 33, baz: 44 })\n```\n\n```text\n // console log output\n\n console.logk  [ 'foo', 'bar', 'baz' ]\n```\n\n## `addToGlobalConsole: (isProd?: boolean | undefined) =\u003e void`\n\n\n-   easy access to library functions with no import needed\n\n```typescript\n// index.js or App.js\nimport { addToGlobalConsole } from 'console-helpers'\n\n// console.logs is now defined\n// console.logk is now defined\naddToGlobalConsole()\n```\n\n```typescript\nimport { addToGlobalConsole } from 'console-helpers'\n\nconst isProd = process.env === 'production'\nconst isDev = process.env !== 'production'\n\n// if dev it adds logs and logk to console\naddToGlobalConsole(/*isDev*/ false)\n\n// if prod it adds () =\u003e {} instead\naddToGlobalConsole(/*isProd*/ true)\n```\n\n#### types\n\n```typescript\nimport { addToGlobalConsole, ExtendedConsole } from 'console-helpers'\n\ndeclare var console: ExtendedConsole\n\naddToGlobalConsole()\n\n// types are ok\nconsole.logs\n// types are ok\nconsole.logk\n```\n\n# Customizing the output\n\n### `logOptionsDefault: () =\u003e InspectOptions`\n\n\n-   you want to see what the lib thinks are good default options it passes to [util.inspect](https://nodejs.org/api/util.html#util_util_inspect_object_options)\n\n```typescript\nimport { logOptionsDefault } from 'console-helpers'\n\n// defaults are: { showHidden: false, depth: null, colors: true, compact: false }\nconsole.log(logOptionsDefault())\n```\n\n#### types\n\n```typescript\nimport { InspectOptions } from 'util'\n\n// @types/node/globals.d.ts\ninterface InspectOptions {\n    /**\n     * If set to `true`, getters are going to be\n     * inspected as well. If set to `'get'` only getters without setter are going\n     * to be inspected. If set to `'set'` only getters having a corresponding\n     * setter are going to be inspected. This might cause side effects depending on\n     * the getter function.\n     * @default `false`\n     */\n    getters?: 'get' | 'set' | boolean;\n    showHidden?: boolean;\n    /**\n     * @default 2\n     */\n    depth?: number | null;\n    colors?: boolean;\n    customInspect?: boolean;\n    showProxy?: boolean;\n    maxArrayLength?: number | null;\n    breakLength?: number;\n    /**\n     * Setting this to `false` causes each object key\n     * to be displayed on a new line. It will also add new lines to text that is\n     * longer than `breakLength`. If set to a number, the most `n` inner elements\n     * are united on a single line as long as all properties fit into\n     * `breakLength`. Short array elements are also grouped together. Note that no\n     * text will be reduced below 16 characters, no matter the `breakLength` size.\n     * For more information, see the example below.\n     * @default `true`\n     */\n    compact?: boolean | number;\n    sorted?: boolean | ((a: string, b: string) =\u003e number);\n}\n```\n\n### `logOptions: () =\u003e InspectOptions;`\n\n\n-   returns log options currently set\n\n```typescript\nimport { logOptions, logOptionsDefault } from 'console-helpers'\n\n// true\nconsole.log(logOptions().toString() === logOptionsDefault().toString())\n```\n\n### `setLogOptions: (options: InspectOptions) =\u003e InspectOptions;`\n\n\n-   set log options to your provided object\n\n```typescript\nimport { setLogOptions } from 'console-helpers'\n\n// logOptions now are: { showHidden: false, colors: false, compact: true, breakLength: 120 }\nconsole.log(setLogOptions({ showHidden: false, colors: false, compact: true, breakLength: 120 }))\n```\n\n### `addLogOptions: (options: InspectOptions) =\u003e InspectOptions;`\n\n\n-   combine defaults with your object, giving your object priority\n\n```typescript\nimport { addLogOptions } from 'console-helpers'\n\n// logOptions now are defaults + { colors: false, breakLength: 120 }: { showHidden: false, depth: null, colors: false, compact: false, breakLength: 120 }\nconsole.log(addLogOptions({ colors: false, breakLength: 120 }))\n```\n\n### `resetLogOptions: () =\u003e InspectOptions;`\n\n\n-   reset log options to lib default\n\n```typescript\nimport { resetLogOptions, addLogOptions, logOptions, logOptionsDefault } from 'console-helpers'\n\naddLogOptions({ colors: false, breakLength: 120 })\n// false because { colors: false, breakLength: 120 } was merged in\nlogOptions().toString() === logOptionsDefault().toString()\n// logOptions now are defaults: { showHidden: false, depth: null, colors: true, compact: false }\nconsole.log(resetLogOptions())\n// true because reset\nlogOptions().toString() === logOptionsDefault().toString()\n```\n\n## To do\n\nBetter browser support with pretty format\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcodes0%2Fconsole-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcodes0%2Fconsole-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcodes0%2Fconsole-helpers/lists"}