{"id":15983020,"url":"https://github.com/ematipico/easy-log","last_synced_at":"2025-04-04T19:19:59.966Z","repository":{"id":57111320,"uuid":"119995836","full_name":"ematipico/easy-log","owner":"ematipico","description":"Simple, combustible and pluggable logger for browser","archived":false,"fork":false,"pushed_at":"2018-08-07T17:10:20.000Z","size":279,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T22:26:19.903Z","etag":null,"topics":["browser","javascript","logger","logging"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ematipico.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-02T15:09:22.000Z","updated_at":"2018-08-07T17:10:01.000Z","dependencies_parsed_at":"2022-08-21T11:00:19.000Z","dependency_job_id":null,"html_url":"https://github.com/ematipico/easy-log","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ematipico%2Feasy-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ematipico%2Feasy-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ematipico%2Feasy-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ematipico%2Feasy-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ematipico","download_url":"https://codeload.github.com/ematipico/easy-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234942,"owners_count":20905855,"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":["browser","javascript","logger","logging"],"created_at":"2024-10-08T01:24:10.977Z","updated_at":"2025-04-04T19:19:59.949Z","avatar_url":"https://github.com/ematipico.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy log\n\n## Simple, combustible and pluggable logger for browser\n\nWith easy log, you can have your own logger and add all the functions that you want.\nYou can set log levels, fallbacks and so one.\n\nAt the end the logger is just a function that modify itself based on your needs\n\n### Installation\n\nWith `npm`\n\n```bash\nnpm i --save @ematipico/easy-log\n```\n\nWith `yarn`\n\n```bash\nyarn add @ematipico/easy-log\n```\n\n### Create a logger\n\n```js\nimport { createLogger } from 'easy-log'\nconst AppLogger = createLogger()\nAppLogger.critical('There\\'s an error here!')\n\n// [CRITICAL] There's an error here!\n```\n\n### Personlise it\n\nWhen creating your logger, you can pass the default level of your logging and an object where you can persolise you logging. Let's see how\n\n```js\nimport { createLogger } from 'easy-log'\nconst levels = {\n  1: {\n    name: 'serious', // the name of the function\n    fn: console.warn // the function itself\n    prefix: '[CAREFUL]'\n  }\n}\nconst logger = createLogger(1, levels)\nlogger.serious('WOOOO IT IS SERIOUS!'); // [CAREFUL] WOOOO IT IS SERIOUS! [with warning style on the console]\n\n```\n\n### `createLogger(defaultLevel, settings)`\n\n| Parameter | Type | Description |\n| ----------|------|-------------|\n| `defaultLevel` | `Number` | The level of logging that your logger will have once created |\n| `settings` | `Object` | An object that will contain the configuration of you log functions |\n\n### The configuration object\n\nSettings object must have numbers as keys of strings that, once coerced, will become the number. Remember that it's better you have simple numbers in order to have everything in order.\n\nBy the default the loggers gives three functions: `.critical`, `.warning` and `.info` with some prefix. You are free to override them.\nLet's see what's inside the settings object.\n\n| Parameter | Type | Description |\n| ----------|------|-------------|\n| `name` | `String` | The name of your function |\n| `fn` | `Function` | The function that will be execture once you will call .name |\n| `prefix` | `String` | A string that will be preprended to your log |\n| `pure` | `Boolean` | When it's `false`, your function will have to return a new function. Useful to integrate with third party libraries, such as `debug` |\n\n```js\n// Integration with debug\nimport { createLogger } from 'easy-log'\nimport debug from 'debug'\nconst levels = {\n  1: {\n    name: 'serious', // the name of the function\n    fn: console.warn // the function itself\n    prefix: '[CAREFUL]'\n  },\n  2: {\n    name: 'debug',\n    fn: function (label) {\n      return debug(label)\n    },\n    pure: false\n  }\n}\nconst logger = createLogger(2, levels)\nlocalStorage.debug = 'dummy:*'\nconst log = logger.debug('dummy:');\nlog('ehy')\nlog('ehy')\nlog('ehy')\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fematipico%2Feasy-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fematipico%2Feasy-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fematipico%2Feasy-log/lists"}