{"id":20252463,"url":"https://github.com/ivandotv/tinga","last_synced_at":"2025-08-21T19:19:56.152Z","repository":{"id":37987061,"uuid":"476469805","full_name":"ivandotv/tinga","owner":"ivandotv","description":"Small 1kb logging module made primarily for the browser. Supports multiple log levels","archived":false,"fork":false,"pushed_at":"2024-03-25T19:02:17.000Z","size":434,"stargazers_count":7,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-25T20:26:13.884Z","etag":null,"topics":["logger","logging","pino"],"latest_commit_sha":null,"homepage":"","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/ivandotv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-03-31T20:35:32.000Z","updated_at":"2024-03-25T20:26:20.506Z","dependencies_parsed_at":"2024-03-06T12:27:45.157Z","dependency_job_id":"dd2fd0c8-7615-4fe7-9e44-007f494738fb","html_url":"https://github.com/ivandotv/tinga","commit_stats":{"total_commits":79,"total_committers":5,"mean_commits":15.8,"dds":0.3291139240506329,"last_synced_commit":"cd01c322469d6b873a7e8237bf6a8aacc477c158"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Ftinga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Ftinga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Ftinga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Ftinga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivandotv","download_url":"https://codeload.github.com/ivandotv/tinga/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313008,"owners_count":21082787,"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":["logger","logging","pino"],"created_at":"2024-11-14T10:16:55.845Z","updated_at":"2025-04-10T23:21:06.672Z","avatar_url":"https://github.com/ivandotv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tinga\n\nSmall browser logging module with the ability to send logs to the remote endpoint\n\n[![Test](https://github.com/ivandotv/tinga/actions/workflows/CI.yml/badge.svg)](https://github.com/ivandotv/tinga/actions/workflows/CI.yml)\n[![Codecov](https://img.shields.io/codecov/c/gh/ivandotv/tinga)](https://app.codecov.io/gh/ivandotv/tinga)\n[![GitHub license](https://img.shields.io/github/license/ivandotv/tinga)](https://github.com/ivandotv/tinga/blob/main/LICENSE)\n\nSmall ([~1KB](https://bundlephobia.com/package/tinga)) logging module primarily for the browser. It has a few logging levels that can be enabled and disabled at runtime.\n\n![screen](./assets/img-1.png)\n\n\u003c!-- toc --\u003e\n\n- [Install](#install)\n- [Motivation](#motivation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n  - [Context](#context)\n  - [Levels](#levels)\n  - [Child instances](#child-instances)\n  - [Examples](#examples)\n\n\u003c!-- tocstop --\u003e\n\n## Install\n\n`npm i tinga`\n\n## Motivation\n\nWhile [pino](https://github.com/pinojs/pino) is an excellent logger for the backend all the functionality is not needed for the frontend, it has a bigger file size, and the default formatting doesn't suit the browser console hence, `Tinga` has been created.\n\n## Usage\n\nUsage is very simple, by default you don't need to pass in any configuration, but I recommend using at least the `label` property for added visibility in the browser console.\n\n```ts\nimport Tinga from 'tinga'\n\nconst logger = new Tinga({ label: 'demo' })\nlogger.log('Hello world')\nlogger.error('Wrong username')\n```\n\n## Configuration\n\nTinga accepts a configuration object to customize the `Tinga` instance.\n\n```ts\nimport Tinga, { type Config } from 'tinga'\n\nconst config: Config = {\n  ctx: { name: 'Ivan' }, // context\n  label: 'demo',\n  processData: (ctx, data, _info: { level: Level; label?: string }) =\u003e {\n    return {\n      ctx,\n      data\n    }\n  }\n}\n\nconst logger = new Tinga(config)\n```\n\n- `ctx`: is additional data that will be logged with every log level.\n- `label`: string to be logged right next to the level.\n- `processData`: a function that is called just before the `data` is logged to the console, it should at least return an object with the `data` property which is an array of data to be passed to the console (as `rest` arguments).\n\n### Context\n\nContext is additional data that can be set per logger instance, that will be passed to every log level. You can `get` and `set` context at runtime.\n\n```ts\nconst looger = new Tinga({ ctx: { name: 'ivan' } })\n\nlogger.getContext()\nlogger.setContext({ name: 'Mario' })\n```\n\n### Levels\n\nSeven levels can be used for logging.\n\n| Name     | Value |\n| -------- | ----- |\n| trace    | 10    |\n| debug    | 20    |\n| info     | 30    |\n| warn     | 40    |\n| error    | 50    |\n| critical | 60    |\n| silent   | 100   |\n\nYou can get and set levels at runtime, all levels above the currently set level will be logged. `silent` level is the only level that is not logged, so if you want to disable logging, you can use the `silent` level.\n\n```ts\nlogger.getLevel()\nlogger.setLevel('silent')\nlogger.getLevels() // get all levels\n```\n\n### Child instances\n\nYou can create a `child` instance of an already created `Tinga` instance, by creating a `child` instance, it will inherit all the configuration properties of the parent.\nChild instances are useful when you want to slightly modify the original version, by for example having a different label, for modifying the parent context. For a child instance, you can directly set the new context, or by passing a `function` as the context property you can derive a new context from the parent context, as the example below shows.\n\n```ts\nconst logger = new Tinga(config)\n\nconst childLogger = logger.child({\n  label: 'new-labels',\n  ctx: (parentCtx) =\u003e {\n    return {\n      ...parentCtx,\n      newProps: 'hello from child'\n    }\n  }\n})\n\nchildLogger.log('helo')\n```\n\n### Examples\n\nCheck out this [Next.js logging demo](https://github.com/ivandotv/nextjs-pino-log-demo) where I'm using (comparing) `Pino` and `Tinga` on the same page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Ftinga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivandotv%2Ftinga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Ftinga/lists"}