# typescript-ezlog

> Easy TypeScript library for logging in Nodejs.

Latest version **0.5.6** (published 2018-02-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install typescript-ezlog
pnpm add typescript-ezlog
yarn add typescript-ezlog
bun add typescript-ezlog
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.6 |
| Published | 2018-02-25 |
| First published | 2018-02-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lennart Zebandt |
| Maintainers | lennart-zebandt |
| Keywords | typescript-logging, logging, colors, log, logger |

## Links

- npm: https://www.npmjs.com/package/typescript-ezlog
- Repository: https://github.com/LennartZebandt/typescript-ezlog
- Homepage: https://github.com/LennartZebandt/typescript-ezlog#readme
- Issues: https://github.com/LennartZebandt/typescript-ezlog/issues
- npm.io page: https://npm.io/package/typescript-ezlog

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) 9.4.5

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.5.6 (latest) — 2018-02-25
- 0.5.4 — 2018-02-20
- 0.5.3 — 2018-02-12
- 0.5.2 — 2018-02-12
- 0.5.1 — 2018-02-12

## README

# typescript-ezlog
Easy TypeScript library for logging in Nodejs.

Not tested yet!

* Easy to integrate in Typescript projects
* Easy to create custom loggers by using generalization
* Easy to save logs to file
* Set loglevel with envoirment variables
* Set tag for file to find dedicated code
* Fucking colorful

## Installation

```bash
npm install --save typescript-ezlog
```

Requires typescript 2.7.1 (tested).

## Usage

```typescript
import { Logger } from 'typescript-ezlog';

const log: Logger = new Logger('tag');

log.err(new Error('error'));
log.warn('warning');
log.info('info');
log.deb('deb');
```

### FileLogger

```typescript
import { FileLogger } from 'typescript-ezlog';

const log: FileLogger = new FileLogger('tag');

log.err(new Error('this goes to console and error.log file'));
log.warn('this goes to console and verbose.log file');
log.info('this goes to console and verbose.log file');
log.deb('this goes to console and verbose.log file');
```

### Custom

```typescript
import { Logger, Level } from 'typescript-ezlog';

class CustomLogger extends Logger { 

    protected log(level: Level, data: string) { 
        //logs to console with color
        this.logToConsole(level, data);
        //do whatever you want
    }

    protected getTimestamp(): string { 
        //return preferred timestamp string
        return '';
    }

    protected transform(level: Level, data: any[]): string { 
        //applies tag, timestamp and builds a string
        return this.transform(level, data);
    }

}
```

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