# express-simple-log

> 这是一个简单的日志记录中间件。 会在 `node` 运行的目录生成一个 `log.json`。 结构如下:

Latest version **1.0.5** (published 2016-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-simple-log
pnpm add express-simple-log
yarn add express-simple-log
bun add express-simple-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.5 |
| Published | 2016-10-15 |
| First published | 2016-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | JSFiend |
| Maintainers | jsfiend |

## Links

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

## Dependencies (1)

- [fs-extra](https://npm.io/package/fs-extra.md) ^0.30.0

## Recent versions

- 1.0.5 (latest) — 2016-10-15
- 1.0.4 — 2016-10-13
- 1.0.3 — 2016-10-12
- 1.0.2 — 2016-10-12
- 1.0.1 — 2016-10-12
- 1.0.0 — 2016-10-12

## README

## express-simle-log

这是一个简单的日志记录中间件。 会在 `node` 运行的目录生成一个 `log.json`。
结构如下:

```javascript
[
    {
        type: "信息",
        content: "你要打印的东西",
        createTime: "new Date()"
    }
]
```

### 安装
> npm install express-simple-log --save

### 使用
```javascript
var express = require('express');
var log = require('express-simple-log');
var app = express();
app.use(log({
    console: true
}))
```
### opt

现在只有个一个参数， 就是 `console`， 默认是 `false`。
当 `opt.console` 设置为 `true` 的时候， 日记内容会 `console` 在控制台打印出来。
like:
```
app.use('/', function(req, res, next){
    req.log('访问首页成功!');
})
// log.josn 就会好像这样
[
    {
        type: "信息",
        content: "访问首页成功",
        createTime: "new Date()"
    }
];

// 控制台会打印出
{type: "信息", content: "访问首页成功",createTime: "new Date()"}
```

### req.log
req.log 办法接受一个参数，可以不传， 得到 log.json 的json 文本。
如果是字符串， 该条日记类型默认为信息 type: "信息"。
如果是对象， 对象结构参考 { type: "成功", content: "添加用户成功！"}

### opt.type == deleteLog
如果日志类型是 `deleteLog`， 那么 `content` 内容应该是类型， 标志要删除的类型
```
// 删除又有类型为 ip 的日志
req.log({
    type: 'deleteLog',
    content: 'ip'
})
```

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