{"id":25270180,"url":"https://github.com/distante/saninn-logger","last_synced_at":"2025-07-22T12:33:28.635Z","repository":{"id":34062524,"uuid":"166853221","full_name":"distante/saninn-logger","owner":"distante","description":"A configurable wrapper around the console object (without losing the console call position)","archived":false,"fork":false,"pushed_at":"2024-03-26T09:40:45.000Z","size":4507,"stargazers_count":7,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T18:45:59.271Z","etag":null,"topics":["browser","console","console-log","es5","es5-javascript","es6","typescript-library"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/distante.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-21T17:27:46.000Z","updated_at":"2023-03-27T22:16:36.000Z","dependencies_parsed_at":"2024-03-26T10:54:40.510Z","dependency_job_id":null,"html_url":"https://github.com/distante/saninn-logger","commit_stats":{"total_commits":183,"total_committers":5,"mean_commits":36.6,"dds":"0.20218579234972678","last_synced_commit":"95bde15a80af0bbc308c2dc011ef35e07285c6d1"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/distante/saninn-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fsaninn-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fsaninn-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fsaninn-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fsaninn-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/distante","download_url":"https://codeload.github.com/distante/saninn-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fsaninn-logger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266495909,"owners_count":23938621,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["browser","console","console-log","es5","es5-javascript","es6","typescript-library"],"created_at":"2025-02-12T11:29:32.981Z","updated_at":"2025-07-22T12:33:28.584Z","avatar_url":"https://github.com/distante.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n  \u003ch1\u003e@saninn/logger\u003c/h1\u003e\r\n\r\n\u003cspan style=\"font-size:2em\"\u003e👨‍💻💻\u003c/span\u003e\r\n\r\nA configurable wrapper of the console that keeps the log call position.\r\n\r\nMade with Typescript, usable as es6 module and iife (with IE10 support).\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n[![Build Status](https://github.com/distante/saninn-logger/actions/workflows/node.js.yml/badge.svg)](https://github.com/distante/saninn-logger/actions/workflows/node.js.yml) [![codecov](https://codecov.io/gh/distante/saninn-logger/branch/master/graph/badge.svg)](https://codecov.io/gh/distante/saninn-logger) [![Known Vulnerabilities](https://snyk.io/test/github/distante/saninn-logger/badge.svg?targetFile=package.json)](https://snyk.io/test/github/distante/saninn-logger?targetFile=package.json) [![Maintainability](https://api.codeclimate.com/v1/badges/f7d99fcb6516cac26fde/maintainability)](https://codeclimate.com/github/distante/saninn-logger/maintainability) ![Licence](https://img.shields.io/github/license/distante/saninn-logger.svg)\r\n\r\n\u003c/div\u003e\r\n\u003c/div\u003e\r\n\r\n\u003chr /\u003e\r\n\r\n## The Problem\r\n\r\nYou need to control when activate or deactivate your app or website logging but when your put `console.log` inside another class or function the console call position is lost. Well not anymore!\r\n\r\n![example][example]\r\n\r\n[example]: https://i.imgur.com/NQSB5f5.png 'Saninn Logger Example'\r\n\r\n## Install\r\n\r\n`npm install @saninn/logger`.\r\n\r\nIf you want to use it as es6, commonjs or iife download the respective assets in the [Releases Page](https://github.com/distante/saninn-logger/releases/). As alternative you can clone this project, run `npm install` and `npm run build-bundles`.\r\n\r\n_Note: The iife version contains a Polyfill for Javascript Proxy Api._\r\n\r\n## What can I do?\r\n\r\n- Set a prefix to all your console calls(log, warn, error, etc) so it is easy to filter while debugging;\r\n- Add a color to each console calls (supported in all browsers but Internet Explorer).\r\n- Set logger levels to prevent console flood (Debug, Info, Warn, Error and Fatal);\r\n- Process external loggers (like server side) with the same call as the local log.\r\n- Process just external loggers.\r\n- Procces just local loggers.\r\n- Register external loggers on run time.\r\n- Remove external loggers on run time.\r\n\r\n## Basic usage\r\n\r\n### Typescript\r\n\r\n```ts\r\nimport { SaninnLogger } from '@saninn/logger';\r\nconst myLogger = new SaninnLogger('my-logger-prefix');\r\nmyLogger.log('this is a log'); // [my-logger-prefix]: this is a log.\r\n```\r\n\r\n### Javascript (es6 module)\r\n\r\n#### index.html\r\n\r\n```html\r\n\u003chead\u003e\r\n  \u003cscript src=\"main.js\" type=\"module\"\u003e\u003c/script\u003e\r\n\u003c/head\u003e\r\n```\r\n\r\n#### main.js\r\n\r\n```js\r\nimport { SaninnLogger } from './node_modules/@saninn/logger/dist/@saninn__logger.js';\r\nconst myLogger = new SaninnLogger('my-logger-prefix');\r\nmyLogger.log('this is a log'); // [my-logger-prefix]: this is a log.\r\n```\r\n\r\n### Javascript (es5)\r\n\r\n- First download the Immediately-invoked function expression (iife) from the [Releases Page](https://github.com/distante/saninn-logger/releases/) and import it before your javascript entry point\r\n\r\n#### index.html\r\n\r\n```html\r\n\u003chead\u003e\r\n  \u003cscript src=\"@saninn__logger.js\"\u003e\u003c/script\u003e\r\n  \u003cscript src=\"main.js\"\u003e\u003c/script\u003e\r\n\u003c/head\u003e\r\n```\r\n\r\n#### main.js\r\n\r\n```js\r\nvar myLogger = new SaninnLogger('my-logger-prefix');\r\nmyLogger.log('this is a log'); // [my-logger-prefix]: this is a log.\r\n```\r\n\r\n## API and Documentation\r\n\r\n- [Configuration](https://logger.saninnsalas.com/interfaces/_models_logger_config_interface_.iloggerconfig.html)\r\n- [API](https://logger.saninnsalas.com/classes/__saninn__logger_.saninnlogger.html)\r\n\r\n* `enableGlobalLoggerFunctions(): void`\r\n* `disableGlobalLoggerFunctions(): void`\r\n* `enableLoggerProcessors(): void`\r\n* `disableLoggerProcessors(): void`\r\n* `addLoggerProcessor(logType: LoggerTypesEnum, loggerProcessor: LoggerProcessor): void`\r\n* `removeLoggerProcessor(logType: LoggerTypesEnum, loggerProcessor: LoggerProcessor): void`\r\n* `setLoggerLevelTo(level: LogLevelsEnum): void`\r\n\r\n**Important!!**\r\n\r\nA log level set to `INFO` will print `logger.log()`, `logger.info()` and `logger.dir()` calls.\r\n\r\nSee the Documentation in [https://logger.saninnsalas.com](https://logger.saninnsalas.com) for full details.\r\n\r\n## Use cases\r\n\r\nYou can see the [Wiki](https://github.com/distante/saninn-logger/wiki) for ideas and use cases where @saninn/logger can help you!\r\n\r\n## Full options example\r\n\r\n```js\r\nconst loggerWithFullConfigAndProcessors = new SaninnLogger({\r\n  useGlobalPreLoggerFunctions: true,\r\n  globalPreLoggerFunctions: {\r\n    dir: (prefix) =\u003e {\r\n      console.log(\r\n        'This is a DIR preLoggerFunction that is not the direct console.dir',\r\n        'This is The Prefix:  ' + prefix\r\n      );\r\n    },\r\n    error: (prefix) =\u003e {\r\n      console.log(\r\n        'This is a ERROR preLoggerFunction that is not the direct console.error',\r\n        'This is The Prefix:  ' + prefix\r\n      );\r\n    },\r\n    log: (prefix) =\u003e {\r\n      console.log(\r\n        'This is a LOG preLoggerFunction that is not the direct console.log',\r\n        'This is The Prefix:  ' + prefix\r\n      );\r\n    },\r\n    warn: (prefix) =\u003e {\r\n      console.log(\r\n        'This is a WARN preLoggerFunction that is not the direct console.warn',\r\n        'This is The Prefix:  ' + prefix\r\n      );\r\n    },\r\n  },\r\n  prefix: 'full-config-logger',\r\n  prefixColors: {\r\n    error: 'blue',\r\n    log: 'green',\r\n    warn: 'red',\r\n  },\r\n  printToConsole: true,\r\n  useLoggerProcessors: true,\r\n  loggerProcessors: {\r\n    log: [\r\n      (prefix, args) =\u003e {\r\n        console.log('FIRST logger Processor para saninnLogger.log');\r\n        console.log('prefix: ', prefix);\r\n        console.log('args: ', args);\r\n      },\r\n      (prefix, args) =\u003e {\r\n        console.log('SECOND logger Processor para saninnLogger.log');\r\n        console.log('prefix: ', prefix);\r\n        console.log('args: ', args);\r\n      },\r\n    ],\r\n  },\r\n});\r\n\r\nconst dummyObject = {\r\n  a: 1,\r\n  b: 2,\r\n  c: {\r\n    d: 3,\r\n    e: 4,\r\n  },\r\n};\r\n\r\nconst dummyFunction = function () {\r\n  console.log('dummy function');\r\n};\r\nloggerWithFullConfigAndProcessors.log('log of loggerWithFullConfigAndProcessors', dummyObject, dummyFunction);\r\nloggerWithFullConfigAndProcessors.warn('warn of loggerWithFullConfigAndProcessors');\r\nloggerWithFullConfigAndProcessors.error('error of loggerWithFullConfigAndProcessors');\r\nloggerWithFullConfigAndProcessors.dir('dir of loggerWithFullConfigAndProcessors');\r\n```\r\n\r\n![console output][output]\r\n\r\n[output]: https://i.imgur.com/LyJFI7R.png 'console output'\r\n\r\n## Use with JEST as test runner.\r\n\r\nIf you use [jest]() as test runner you need to tell jest not to transform _@saninn/logger_ using this in your jest config:\r\n\r\n```\r\ntransformIgnorePatterns: ['\u003crootDir\u003e/node_modules/(?!@saninn|@someOtherPackage)']\r\n```\r\n\r\n## License\r\n\r\n[MIT](/LICENSE)\r\n\r\n## Development\r\n\r\nThis project uses:\r\n\r\n- [Typescript](https://www.npmjs.com/package/typescript) in strict mode.\r\n- [Prettier](https://github.com/prettier/prettier) as code formater.\r\n- [commitlint](https://github.com/marionebl/commitlint) to assure the commits follow the [conventional commit format](https://www.conventionalcommits.org/).\r\n- [jest](https://jestjs.io/) as test runner.\r\n\r\n### Scripts\r\n\r\nThere are 3 scripts I use together for dev (each in their own console): 'watch', 'serve' and 'test'.\r\n\r\n- 'npm run watch' will look for Typescript changes and compile it to es6.\r\n- 'npm run serve' will load a local server with './index-es6.html' as entry point. It uses './script.js' as module loader.\r\n- 'npm run test -- --watch --coverage --silent' will run jest tests on each typescript change.\r\n\r\n### ToDo\r\n\r\n- Pack all development scripts into just one...\r\n- [Project](https://github.com/distante/saninn-logger/projects/1)\r\n\r\n## Pull requests are welcome\r\n\r\n❤\r\n\r\n# Find me 🏃‍\r\n\r\n- Website [https://www.saninnsalas.com](https://www.saninnsalas.com)\r\n- Twitter [@SaninnSalas](https://twitter.com/saninnsalas)\r\n- Facebook [@SaninnSalas](https://www.facebook.com/SaninnSD/)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistante%2Fsaninn-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistante%2Fsaninn-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistante%2Fsaninn-logger/lists"}