Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fliegwerk/logsemts
A semantic logging solution implemented with TypeScript
https://github.com/fliegwerk/logsemts
browser color color-coded dev-tools javascript logger logging nodejs semantic typescript
Last synced: 3 months ago
JSON representation
A semantic logging solution implemented with TypeScript
- Host: GitHub
- URL: https://github.com/fliegwerk/logsemts
- Owner: fliegwerk
- License: mit
- Created: 2020-08-26T15:11:17.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T23:09:13.000Z (9 months ago)
- Last Synced: 2024-05-28T22:18:04.413Z (9 months ago)
- Topics: browser, color, color-coded, dev-tools, javascript, logger, logging, nodejs, semantic, typescript
- Language: TypeScript
- Homepage: https://fliegwerk.github.io/logsemts/
- Size: 1.3 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![]()
# @fliegwerk/logsemts - A modular, semantic logger written in TypeScript
[npm package](https://npmjs.com/package/@fliegwerk/logsemts)
| [Library Documentation](https://fliegwerk.github.io/logsemts)![CI](https://github.com/fliegwerk/logsemts/workflows/CI/badge.svg)
![ShiftLeft Scan](https://github.com/fliegwerk/logsemts/workflows/ShiftLeft%20Scan/badge.svg)
![CodeQL](https://github.com/fliegwerk/logsemts/workflows/CodeQL/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/fliegwerk/logsemts/badge.svg?branch=master)](https://coveralls.io/github/fliegwerk/logsemts?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/c2d8d3ab896d0bb100ea/maintainability)](https://codeclimate.com/github/fliegwerk/logsemts/maintainability)
[![Rate on Openbase](https://badges.openbase.io/js/rating/@fliegwerk/logsemts.svg)](https://openbase.io/js/@fliegwerk/logsemts?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)A modular, color-coded, TypeScript-based semantic logger that can be used in NodeJS, the browser and in many other scenarios.
## Example
```ts
// Import the logger:
import Logger, { BrowserLogger } from '@fliegwerk/logsemts';// Create a new logger
const logger = new Logger({
loggers: [BrowserLogger()] // that exclusively outputs to the browser dev tools
});// get a new subsystem logger for the API Client
const apiClientLogger = logger.getComponentLogger('API Client');// log a success message
apiClientLogger.success('Data fetched successfully');
```## Installation
```shell script
$ npm install @fliegwerk/logsemts
```or
```shell script
$ yarn add @fliegwerk/logsemts
```## Concept
![Concept Overview Diagram](assets/drawio/concept-overview.png)
There are three primary components in logsemts:
- _Component Loggers_: Logger objects for specific subsystems (for example, an API connector and a login form).
These objects contain functions like `.log()`, `.debug()`, `.warn()`, etc. to log messages regarding this subsystem.
- _Log Functions_: Functions that log a message to a specific target. Targets could be the Browser's Developer tools, a
Database and an API.
- _Core_: The library's core consists of the `Logger` class. Usually, only one instance of that class gets used in an
application. It manages the different components (_Component Loggers_ get created using the
`logger.getComponentLogger(name)` function) and _Log Functions_. It also forwards the messages from the _Component
Loggers_ to the registered _Log Functions_.