# @tne/logger

> Common logger for Node.js projects

Latest version **1.3.0** (published 2019-04-17) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install @tne/logger
pnpm add @tne/logger
yarn add @tne/logger
bun add @tne/logger
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2019-04-17 |
| First published | 2018-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.14.4 |
| Dependencies | 5 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hugo Virgen |
| Maintainers | virgenherrera |
| Keywords | typescript, node, winston, sysLog, dailyRotation |

## Links

- npm: https://www.npmjs.com/package/@tne/logger
- Repository: https://github.com/virgenherrera/tne-logger
- Homepage: https://github.com/virgenherrera/tne-logger#readme
- Issues: https://github.com/virgenherrera/tne-logger/issues
- npm.io page: https://npm.io/package/@tne/logger

## Dependencies (5)

- [rimraf](https://npm.io/package/rimraf.md) ^2.6.3
- [flatted](https://npm.io/package/flatted.md) ^2.0.0
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [@tne/common](https://npm.io/package/@tne/common.md) ^1.0.1
- [winston-daily-rotate-file](https://npm.io/package/winston-daily-rotate-file.md) ^3.8.0

## 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

- 1.3.0 (latest) — 2019-04-17
- 1.2.2 — 2019-01-24
- 1.2.1 — 2018-11-21
- 1.2.0 — 2018-11-17
- 1.1.2 — 2018-09-25
- 1.1.1 — 2018-09-25
- 1.1.0 — 2018-09-24
- 1.0.2 — 2018-09-24
- 1.0.1-beta — 2018-09-24
- 1.0.0 — 2018-09-24

## README

# @tne/logger
A basic logger for __Node.js__ applications, completely written with __typescript__, is not only the basic logger for the entire `@tne` platform, since being completely decoupled from tne is free to use for any other application __Node.js__

<a name="main_menu"></a>
## Menu
### [Installation](#installation)
### [@tne/logger](#tne_logger)
### [interfaces](#app_interfaces)
- [ISettings](#i_settings)
- [IFileSettings](#i_file_settings)


---
<a name="installation"></a>
[Back to Menu](#main_menu)
## Installation
You can install through the node package managers:

### NPM
```
$ npm i -S @tne/logger
```

### Yarn
```
$ yarn add @tne/logger
```

---
<a name="tne_logger"></a>
[Back to Menu](#main_menu)
## @tne/logger
`@tne/logger` is the main library which is responsible for making 'winston' coverage and standardizing the use for @tne.
[@tne/logger](#tne_logger)

### Example basic usage
just create an instance without providing arguments
```
import { TneLogger } from '@tne/logger';

// create a simple console logger
const logger = new TneLogger;

logger.info('hello!')	// outputs-> [timestamp] info: hello!
logger.info('message 1537574380254');	// outputs -> [timestamp] info: message 1537574380254
logger.warn('message 1537574380254');	// outputs -> [timestamp] warn: message 1537574380254
logger.error('message 1537574380254');	// outputs -> [timestamp] error: message 1537574380254
```

### Example usage with file logger
provide a config object that implements the [ISettings](#i_settings) interface
```
import { TneLogger } from '@tne/logger';

// ISettings
const config = {
	fileCfg: {
		logsPath: process.pwd() + '/logs',
		logFile: 'someFileName',
	}
};


// create a console logger with file persistence
const logger = new TneLogger(config);

logger.info('hello!')	// outputs-> [timestamp] info: hello!
logger.info('message 1537574380254');	// outputs -> [timestamp] info: message 1537574380254
logger.warn('message 1537574380254');	// outputs -> [timestamp] warn: message 1537574380254
logger.error('message 1537574380254');	// outputs -> [timestamp] error: message 1537574380254
```
The above code will also dump logs to a several logs files placed on path specified by `logsPath` argument.

---
<a name="app_interfaces"></a>
[Back to Menu](#main_menu)
### Interfaces
The interfaces that this library provides and that are described here provide help to the developer that will consume this library to build incredible web applications.

#### Constraints
The interfaces mentioned in this section will be importable only if you are developing your web application with `typescript`.

---
<a name="i_settings"></a>
[Back to Menu](#main_menu)
### ISettings
Used as a constructor argument for `TneLogger` class.

#### Parameters
|Param|Type|Required?|Description|
|-|-|-|-|
| level | string | false | [winston logging level](https://github.com/winstonjs/winston#logging-levels) |
| fileCfg | IFileSettings| false | [IFileSettings](#i_file_settings) object |
| customTransports | Transport[] | false | A custom [`winston-transport`](https://github.com/winstonjs/winston-transport) Array.|

---
<a name="i_settings"></a>
[IFileSettings](#i_file_settings)
[Back to Menu](#main_menu)
### IFileSettings
Used as a nested config on constructor argument for `TneLogger` class.

When you provide this config object a log file will be created per day.

#### Parameters
|Param|Type|Required?|Description|
|-|-|-|-|
| logsPath | string | true | valid path where `TneLogger` will create the log files. |
| logFile | string | false | filename for the further log files `default: 'log.log'` |
| datePattern | string | false | data pattern for the further log files `default: 'YYYMMDD'` |

[Back to Menu](#main_menu)

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