{"id":16698064,"url":"https://github.com/arlac77/loglevel-mixin","last_synced_at":"2025-04-10T02:54:42.553Z","repository":{"id":3148459,"uuid":"48580907","full_name":"arlac77/loglevel-mixin","owner":"arlac77","description":"mixin to declare logging methods named after a given set of log levels","archived":false,"fork":false,"pushed_at":"2025-04-05T11:35:58.000Z","size":3340,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T12:27:12.496Z","etag":null,"topics":["logging","loglevel","mixin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arlac77.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":"2015-12-25T13:09:43.000Z","updated_at":"2025-04-05T11:36:01.000Z","dependencies_parsed_at":"2023-09-23T05:13:22.436Z","dependency_job_id":"6cf38485-d38f-4a48-bc53-bc82398bc1b2","html_url":"https://github.com/arlac77/loglevel-mixin","commit_stats":null,"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Floglevel-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Floglevel-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Floglevel-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Floglevel-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arlac77","download_url":"https://codeload.github.com/arlac77/loglevel-mixin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248147403,"owners_count":21055540,"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":["logging","loglevel","mixin"],"created_at":"2024-10-12T17:50:36.458Z","updated_at":"2025-04-10T02:54:42.531Z","avatar_url":"https://github.com/arlac77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/loglevel-mixin.svg)](https://www.npmjs.com/package/loglevel-mixin)\n[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)\n[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\\\u0026label\\\u0026labelColor=blue\\\u0026color=555555)](https://typescriptlang.org)\n[![bundlejs](https://deno.bundlejs.com/?q=loglevel-mixin\\\u0026badge=detailed)](https://bundlejs.com/?q=loglevel-mixin)\n[![downloads](http://img.shields.io/npm/dm/loglevel-mixin.svg?style=flat-square)](https://npmjs.org/package/loglevel-mixin)\n[![GitHub Issues](https://img.shields.io/github/issues/arlac77/loglevel-mixin.svg?style=flat-square)](https://github.com/arlac77/loglevel-mixin/issues)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Floglevel-mixin%2Fbadge\\\u0026style=flat)](https://actions-badge.atrox.dev/arlac77/loglevel-mixin/goto)\n[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/loglevel-mixin/badge.svg)](https://snyk.io/test/github/arlac77/loglevel-mixin)\n[![Coverage Status](https://coveralls.io/repos/arlac77/loglevel-mixin/badge.svg)](https://coveralls.io/github/arlac77/loglevel-mixin)\n\n# loglevel-mixin\n\nInjects methods named after a set of logLevels which are only forwarding messages. If the current logLevel is higher or equal to the logLevel the name of the called method reflects.\n\nSo the model object itself can be used as a logger and the log level is directly attaches to the model\n\n# usage\n\n\u003c!-- skip-example --\u003e\n\n```javascript\nimport { LogLevelMixin } from 'loglevel-mixin';\n\nconst LoggingEnabledClass = LogLevelMixin(\n  class BaseClass {\n    log(level, message) {\n      console.log(`${level} ${message}`);\n    }\n  }\n);\n\nconst someObject = new LoggingEnabledClass();\n\nsomeObject.logLevel = 'error';\nsomeObject.info(\n  severity =\u003e 'my info message (not reported since logLevel is error)'\n);\nsomeObject.logLevel = 'info';\nsomeObject.info(\n  severity =\u003e 'my info message (reported since logLevel is now info)'\n);\n```\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```shell\nnpm install loglevel-mixin\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [Logger](#logger)\n    *   [Properties](#properties)\n*   [Loglevel](#loglevel)\n    *   [Properties](#properties-1)\n*   [defaultLogLevels](#defaultloglevels)\n*   [declareLevels](#declarelevels)\n    *   [Parameters](#parameters)\n*   [defineLoggerMethods](#defineloggermethods)\n    *   [Parameters](#parameters-1)\n    *   [Examples](#examples)\n*   [LogLevelMixin](#loglevelmixin)\n    *   [Parameters](#parameters-2)\n    *   [Examples](#examples-1)\n*   [makeLogEvent](#makelogevent)\n    *   [Parameters](#parameters-3)\n\n## Logger\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n### Properties\n\n*   `entry` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n## Loglevel\n\nType: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n### Properties\n\n*   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**\u0026#x20;\n*   `priority` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**\u0026#x20;\n\n## defaultLogLevels\n\ndefault log levels\n\n*   trace\n*   debug\n*   info\n*   notice\n*   warn\n*   error\n*   crit\n*   alert\n\n## declareLevels\n\nGenerate the loglevel objects out of a list of log level names.\n\n### Parameters\n\n*   `list` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\u003c[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** A list of log level names. The last name in the list will become the one with the highest priority.\n\nReturns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** levels object a hash with all the loglevels. Stored by there name.\n\n## defineLoggerMethods\n\n\u003c!-- skip-example --\u003e\n\nAdds logging methods to an existing object.\nFor each loglevel a method with the name of the log level will be created.\n\n### Parameters\n\n*   `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target where to assign properties to\n*   `logLevels` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Hash with all the available loglevels. Stored by there name (optional, default `defaultLogLevels`)\n*   `theFunction` **[Logger](#logger)?** to be added under the loglevel name.\n    This function will only be called if the current loglevel is greater equal\n    the log level of the called logging function.\n    By default a method log(level,message) will be used\n\n### Examples\n\n```javascript\ndefineLoggerMethods( obj)\nobj.info('info entry'); // will redirect to theFunction if obj.loglevel is at least info\nobj.error('error entry'); // will redirect to theFunction if obj.loglevel is at least error\n```\n\nReturns **void**\u0026#x20;\n\n## LogLevelMixin\n\n\u003c!-- skip-example --\u003e\n\n### Parameters\n\n*   `superclass` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** class to be extendet\n*   `logLevels` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object with all the available loglevels. Stored by their name (optional, default `defaultLogLevels`)\n*   `initialLogLevel` **[Loglevel](#loglevel)** the default value for the logLevel property (optional, default `defaultLogLevels.info`)\n\n### Examples\n\n```javascript\nimport { LogLevelMixin } = from 'loglevel-mixin';\nclass BaseClass {\n  log(level, message) { console.log(`${level} ${message}`); }\n}\nclass LoggingEnabledClass extends LogLevelMixin(BaseClass) {\n}\n```\n\nReturns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** newly created class ready to be further extendet/used\n\n## makeLogEvent\n\nHelper function to aggregate values into a log event.\n\n### Parameters\n\n*   `severity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** log severity\n*   `arg` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** original log message - level may be overwritten\n*   `args` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** additional values to be merged into the final log event - values have precedence\n\nReturns **{message: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}** } suitable for log event processing\n\n# license\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Floglevel-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farlac77%2Floglevel-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Floglevel-mixin/lists"}