{"id":19232034,"url":"https://github.com/dharfr/badgee","last_synced_at":"2025-04-21T04:32:05.567Z","repository":{"id":18837997,"uuid":"22053709","full_name":"dharFr/badgee","owner":"dharFr","description":"Browser Console Improved","archived":false,"fork":false,"pushed_at":"2022-12-30T18:18:33.000Z","size":2923,"stargazers_count":26,"open_issues_count":18,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-09T07:43:21.403Z","etag":null,"topics":["console-error","console-log","devtools","javascript","library","logger"],"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/dharFr.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":"2014-07-21T06:10:28.000Z","updated_at":"2023-10-25T14:03:45.000Z","dependencies_parsed_at":"2023-01-13T20:02:19.972Z","dependency_job_id":null,"html_url":"https://github.com/dharFr/badgee","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharFr%2Fbadgee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharFr%2Fbadgee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharFr%2Fbadgee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dharFr%2Fbadgee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dharFr","download_url":"https://codeload.github.com/dharFr/badgee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223849429,"owners_count":17213640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["console-error","console-log","devtools","javascript","library","logger"],"created_at":"2024-11-09T16:05:12.117Z","updated_at":"2024-11-09T16:05:12.716Z","avatar_url":"https://github.com/dharFr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# badgee.js\n\nA browser console improvement, in less than 1 kB\n\n[![npm version](https://img.shields.io/npm/v/badgee.svg)](https://www.npmjs.com/package/badgee)\n[![Build Status](https://travis-ci.org/dharFr/badgee.svg?branch=master)](https://travis-ci.org/dharFr/badgee)\n[![Greenkeeper badge](https://badges.greenkeeper.io/dharFr/badgee.svg)](https://greenkeeper.io/)\n[![gzip size](http://img.badgesize.io/https://unpkg.com/badgee@latest/build/badgee.js?compression=gzip)](https://unpkg.com/badgee@latest/build/badgee.js)\n\n## What is `badgee`?\n\nIt's an add-on to the browser console, created to improve readability and flexibility. \nIt provides the same API than your brower console, adding a few extra features.\n\n![overview](https://olivier.audard.net/assets/badgee/complete.png)\n\n## Install with NPM\n\n```\nnpm install --save badgee\n```\n\n## Compatibility\n\nWork pretty well in Chrome, Firefox Web Console or Firebug and Safari desktop.\n\n## Overview\n\n`badgee` is superset of the `console` object. \nYou can start using it without configuration as you usually do with `console` object.\n\n```js\nbadgee.log('Configuring badgee...');\n```\n\u003e ![simple-log](https://olivier.audard.net/assets/badgee/step-1.png)\n\n### Configuration\n\nA simple configuration object allows to:\n - enable/disable logs globally\n - enable/disable styled badges globally\n\nDefault configuration is: `{ enabled: true, styled: true }`\n\n```js\nbadgee.config({\n  enabled: true,\n  styled: false\n});\n```\n\nCalled without any arguments, the `config` method returns the current configuration\n\n```js\nbadgee.log( 'Config set to:', badgee.config() );\n```\n\u003e ![config](https://olivier.audard.net/assets/badgee/step-2.png)\n\n### Defining a new badgee instance\n\nThe `define()` method creates a new badgee instance identified by the first argument. The second argument points to an already defined style.\nThe returned object works the same way as `console` or `badgee` objects, but every console output is prefixed with a \"green\" styled badge.\n\n```js\nvar helloBadge = badgee.define('Hello', 'green');\nhelloBadge.log('hello badge defined!');\n```\n\u003e ![define](https://olivier.audard.net/assets/badgee/step-3.png)\n\n### Styling badges\n\nThere is already a few styles defined for your badges.\nYou can list them all using the `style()` method without any argument.\n\n```js\nbadgee.log('Default styles for your badgee:', badgee.style());\n// Default styles for your badgee: [\"green\", \"orange\", \"red\"]\n```\n\u003e ![styles](https://olivier.audard.net/assets/badgee/step-4.png)\n\nYou can define your own badge style by calling the `style()` method with a name and a list of properties.\n\n```js\nbadgee.style('super_important', {\n  color          : 'white',\n  background     : 'red',\n  'font-size'    : '15px',\n  'font-weight'  : 'bold',\n  'border-radius': '2px',\n  padding        : '1px 3px',\n  margin         : '0 1px'\n});\n```\n\nThe style list gets updated after defining a new style.\n\n```js\nbadgee.log('Added \"super_important\" style to the list:', badgee.style());\n// Added \"super_important\" style to the list: [\"green\", \"orange\", \"red\", \"super_important\"]\n```\n\u003e ![style](https://olivier.audard.net/assets/badgee/step-5.png)\n\nOnce a new style is defined, it can be used to define a new badge.\n\n```js\nvar importantBadge = badgee.define('Important', 'super_important');\nimportantBadge.log(\"Don't miss this one!\");\n```\n\u003e ![define](https://olivier.audard.net/assets/badgee/step-6.png)\n\n### Reusing badgee instances\n\nSomewhere else in your application, you may want to reuse an existing badge. \nGet it back by calling the `get()` method with the badge identifier as a first argument.\n\n```js\nvar helloBadge = badgee.get('Hello');\nhelloBadge.log('Using Hello badge from another module');\n```\n\u003e ![get](https://olivier.audard.net/assets/badgee/step-7.png)\n\n### Nested badges\n\nYou can also use the `define()` method on an existing badgee instance to define a nested badge.\nThe newly defined object is still a `badgee` instance. \nBut every console output will be prefixed with two badges instead of one.\n\n```js\nvar helloWorldBadge = helloBadge.define('world', 'purple');\nhelloWorldBadge.log('hello world badge defined!');\n```\n\u003e ![define](https://olivier.audard.net/assets/badgee/step-8.png)\n\nAs any badgee instance is a 'console' superset, you can also use any other `console` method, as you used to.\n\n```js\nhelloBadge.group('Creating a \"group\"');\n  helloBadge.debug('This is a \"debug\"');\n  helloBadge.info('This is a\" info\"');\n  helloWorldBadge.warn('This is a \"warn\"');\n  helloWorldBadge.error('This is an \"error\"');\nhelloBadge.groupEnd();\n```\n\u003e ![group](https://olivier.audard.net/assets/badgee/step-9.png)\n\nSome methods can be prefixed with a badge but are still available for convenience.\n\n```js\nhelloBadge.groupCollapsed('Creating a \"groupCollapsed\"');\n  // 'clear()' method is also available but commented for obvious reason\n  // helloBadge.clear();\n  helloBadge.dir({a: 'this is', b: 'a dir'});\nhelloBadge.groupEnd(); // 'groupEnd()' is available to match with 'groupCollapsed()'\n```\n\n_*Note*_: Since `v2.0.0`, most unformatable methods have been removed from badgee support. \nPlease use `console` object directly for `assert`, `count`, `exception`, `markTimeline`, `profile`, `profileEnd`, \n`table`, `trace`, `time`, `timeEnd`, `timeStamp`, `timeline`, `timelineEnd`.\n\n### Filtering\n\nbadgee allows you to define inclusive and exclusive filters. Those filters are applied globally to every single defined instance.\nFilters are cummulative. You can define both an inclusive and a exclusive filter.\n\n#### Inclusive filter\n\nDefining a global inclusive filter.\nOnly outputs logs from loggers that match the defined filter.\n\n```js\nbadgee.filter.include(/hello/i);\n\nhelloBadge.log('Filter: matches /hello/i : not filtered');\nhelloWorldBadge.log('Filter: matches /hello/i : not filtered');\nimportant.log('Filter: matches /hello/i : filtered, won\\'t be displayed');\nstyledBadge.log('Filter: matches /hello/i : filtered, won\\'t be displayed');\n```\n\n#### Exclusive filter\n\nDefining a global exclusive filter\nOutput every logs except those from loggers that match the filter.\n\n```js\nbadgee.filter.exclude(/world/i);\n\nhelloBadge.log('Filter: doesn\\'t match /world/i : not filtered');\nhelloWorldBadge.log('Filter: doesn\\'t match /world/i : filtered - won\\'t be displayed');\n```\n\n#### Cleaning filters\n\nRemove already defined filters.\n\n```js\nbadgee.filter.none();\n```\n\n## API\n\n### `badgee.config([settings])`\n\nUpdate the configuration with the provided `settings` object. Or returns the current configuration when called without parameter.\n\n - `settings` (Optionnal)\n   Type: Object\n   A set of key/value pairs to configure the badges\n   \n   - `enabled` (default: `true`)  \n     Type: boolean  \n     If set to `false`, logs will no longer be displayed to the console. Otherwise logs are displayed as usual\n\n   - `styled` (default: `true`)  \n      Type: boolean  \n      If set to `false`, label prefixes will be displayed with default output style. Otherwise, label prefixes will be formated as defined by `style` property (see ).\n\n### `badgee.style([name], [style])`\n\nWhen called without parameters, returns the list of already defined styles.\n\n - `name`\n    Type: String\n    The name of the new style to define/retrive.\n - `style`\n    Type: Object\n    A set of key/value pairs to define a CSS style for badges.\n\n### `badgee.defaultStyle([style])`\n\nWhen called without parameters, returns the current default styles.\n\n - `style`\n    Type: Object\n    A set of key/value pairs to apply by defaultwhen defining a new style for badges.\n \n### `badgee.define(label, style)`\n\nCreates and returns a new badgee instance, for which every console output will be prefixed with the provided `label`, formated according to provided `style` definition.\n\n - `label`  \n   Type: String  \n   The name of the badgee instance\n   \n - `style`  \n   Type: String  \n   The name of an already defined badgee style (see `badgee.style()`)\n   \n### `badgee.get(label)`\n\nReturns an existing badgee instance, identified by its `label`\n\n - `label`  \n   Type: String  \n   The name of the badgee instance\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdharfr%2Fbadgee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdharfr%2Fbadgee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdharfr%2Fbadgee/lists"}