# simple-koa-log

> simple koa log

Latest version **1.0.1** (published 2019-05-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install simple-koa-log
pnpm add simple-koa-log
yarn add simple-koa-log
bun add simple-koa-log
```

## 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 | 1.0.1 |
| Published | 2019-05-06 |
| First published | 2019-05-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | suohongbo |
| Maintainers | suohongbo |
| Keywords | koa-log, log, log2file |

## Links

- npm: https://www.npmjs.com/package/simple-koa-log
- Repository: https://github.com/shb190802/simple-koa-log
- Homepage: https://github.com/shb190802/simple-koa-log#readme
- Issues: https://github.com/shb190802/simple-koa-log/issues
- npm.io page: https://npm.io/package/simple-koa-log

## 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.0.1 (latest) — 2019-05-06
- 1.0.0 — 2019-05-06

## README

# simple-koa-log
simple koa log

install
----
```javascript
npm install simple-koa-log
```


use
---
```javascript
const Koa = require('koa')
const KoaRouter = require('koa-router')
const log = require('simple-koa-log')
var app = new Koa();
var router = new KoaRouter();

router.get('/error',(ctx,next)=>{
    throw new Error('err111')
    log.info('on error')
    ctx.body = 'test'
    next()
})
router.get('/',(ctx,next)=>{
    log.info('on root')
    ctx.body = 'hello world' ;
    next();
})
app.onerror = (err)=>{
    for(var key in err){
        console.log(key,err[key]);
    }
    log.error(err.message);
}
app.use(router.routes())
    .use(router.allowedMethods())
    .use(ctx=>{
        log.access(ctx.url);
    })
app.listen(8080)
```
default log path
----
YOU_PROJECT_ROOT/logs/access-2019-05-06.log<br>
YOU_PROJECT_ROOT/logs/error-2019-05-06.log<br>
YOU_PROJECT_ROOT/logs/info-2019-05-06.log<br>


config
---
```javascript
//subPaht & fileName support format "YYYY-MM-DD hh:mm:ss"
log.config({
    path: './path',
    subPath: 'YYYY-MM',
    fileName: '-DD-log.txt'
})
```
log path
---
YOU_PROJECT_ROOT/path/2019-05/access-06-log.txt<br>
YOU_PROJECT_ROOT/logs/2019-05/error-06-log.txt<br>
YOU_PROJECT_ROOT/logs/2019-05/info-06-log.txt<br>

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