# ts-logger-service

> Simple logger in typescript

Latest version **1.2.0** (published 2019-04-14) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ts-logger-service
pnpm add ts-logger-service
yarn add ts-logger-service
bun add ts-logger-service
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-04-14 |
| First published | 2019-04-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 42.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mattia D'Argenio |
| Maintainers | darge |

## Links

- npm: https://www.npmjs.com/package/ts-logger-service
- Repository: https://github.com/darge98/ts-logger-service
- Homepage: https://github.com/darge98/ts-logger-service#readme
- Issues: https://github.com/darge98/ts-logger-service/issues
- npm.io page: https://npm.io/package/ts-logger-service

## Dependencies (1)

- [webpack](https://npm.io/package/webpack.md) ^4.30.0

## Recent versions

- 1.2.0 (latest) — 2019-04-14
- 1.1.9 — 2019-04-14
- 1.1.8 — 2019-04-14
- 1.1.7 — 2019-04-14
- 1.1.6 — 2019-04-14
- 1.1.5 — 2019-04-14
- 1.1.4 — 2019-04-14
- 1.1.3 — 2019-04-14
- 1.1.2 — 2019-04-14
- 1.1.1 — 2019-04-14
- 1.1.0 — 2019-04-14
- 1.0.1 — 2019-04-14
- 1.0.0 — 2019-04-14

## README

# Logger

Simple library written in Typescript.

## Installation

Use npm to install the package:

```bash
npm install ts-logger-service
```

The package has been tested with typescript 3.4.3. 
> **Important** <br/> 
> Full support for different versions is not guaranteed.

## 
## Usage

### Create and use logger

#### Use the Factory

Every logger is instantiated into `LoggerFactory`. LoggerFactory provide static method to create and get a Logger.

> ```typescript
> LoggerFactory.instanceLogger('foo', LoggerLevels.INFO, new ConsoleLoggerService());
> const logger = LoggerFactory.getLogger('foo');
> logger.info('logger info'); // printed
> logger.error('logger error'); // not printed
> ```
>
> In this example we create a new Logger named `foo`, set its level to `INFO` and provide his service that manage every single log (see [LoggerService]()).
>
> After created we get the Logger from LoggerFactory by its name and call methods info and error to print in console. Here the result
>
> ![1555267406390](C:\Users\darge\AppData\Roaming\Typora\typora-user-images\1555267406390.png)
>
> #### Use decorator
>
> Work in progress...

### Create custom LoggerService

It's possible create custom LoggerService to specify behaviour for the logger. We must extends the abstract class `LoggerService`

```typescript
export class CustomLoggerService extends LoggerService {

    // Console print
	debug(message: string): void {
		console.debug(message);
	}
    // Send error to API
	error(message: string): void {	
        this.http.post('http://log-api.it', {
            level: 'error'
            message: message
        })
	}
    // Write info into file
	info(message: string): void {
		fs.appendfile('log.txt', message);
	}
    .
    .
    .
}
```

It's in working the possibility to split the message in some different part (example logName, message, Date) to provide a more flessibility to the LoggerService.

## Documentation
See [HERE]()

## License
Licenza MIT (todo)

Add copyright

---
_Source: https://npm.io/package/ts-logger-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
