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: 2 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 (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T23:09:13.000Z (about 1 year ago)
- Last Synced: 2024-05-28T22:18:04.413Z (about 1 year 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)


[](https://coveralls.io/github/fliegwerk/logsemts?branch=master)
[](https://codeclimate.com/github/fliegwerk/logsemts/maintainability)
[](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

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_.