# @umajs/plugin-logger

> umajs logger日志插件

Latest version **2.1.0** (published 2022-09-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @umajs/plugin-logger
pnpm add @umajs/plugin-logger
yarn add @umajs/plugin-logger
bun add @umajs/plugin-logger
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2022-09-29 |
| First published | 2020-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | dazjean |
| Maintainers | bubblem, edwwardzzz, dazjean, cocoboom, liushaohua, wangliang826 |

## Links

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

## Dependencies (1)

- [@umajs/logger](https://npm.io/package/@umajs/logger.md) ^2.1.0

## Recent versions

- 2.1.0 (latest) — 2022-09-29
- 2.0.0 — 2021-11-22
- 0.1.1 — 2020-09-15
- 0.1.0 — 2020-05-14

## README

# `@umajs/plugin-logger`

> umajs框架日志插件,挂载到koa上下文ctx上。

## Usage

```
npm install @umajs/plugin-logger --save

```
## logger插件配置
```
//app/src/config/plugin.config.ts
import * as path from 'path';
import Uma from '@umajs/core';
export default {
    logger: {
        enable: true,
        options: {
            level: 'DEBUG', //日志输出级别
            file: path.resolve(Uma.instance().options.ROOT, '../log/ctxLogger.log'),
            allowDebugAtProd: false, // 是否允许打印debug日志
            replaceConsole:false, //是否重写系统console日志
        },
    }
}
```

## 使用
```
//使用 app/src/controller/index.controller.ts
export default class Index extends Controller {
    @Path('/index')
    @RequestMethod('GET')
    index() {
        this.ctx.logger.info(this.testService.return1());
        this.ctx.logger.debug('debug');
        this.ctx.logger.warn('warn');
        this.ctx.logger.error('error');
        this.ctx.body = '这里是首页';
    }
}
```

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