An open API service indexing awesome lists of open source software.

https://github.com/zthxxx/dont-care-log

make git stage ignore specific log code line
https://github.com/zthxxx/dont-care-log

console-log console-plugin git-diff-ignore git-diff-plugin git-ignore-log git-ignore-plugin git-plugin ignore-console-log turbo-console-log

Last synced: 2 months ago
JSON representation

make git stage ignore specific log code line

Awesome Lists containing this project

README

          

# dont-care-log

[![Build Status](https://img.shields.io/travis/zthxxx/dont-care-log)](https://travis-ci.org/zthxxx/dont-care-log)
[![NPM Version](https://img.shields.io/npm/v/dont-care-log)](https://www.npmjs.com/package/dont-care-log)
[![NPM Downloads](https://img.shields.io/npm/dt/dont-care-log)](https://www.npmjs.com/package/dont-care-log)
[![Node.js](https://img.shields.io/node/v/dont-care-log)](https://nodejs.org)
[![LICENSE](https://img.shields.io/github/license/zthxxx/dont-care-log)](https://github.com/zthxxx/dont-care-log/blob/master/LICENSE)

Teach git stage/diff how to **ignore specific logging code**,

so your logging code will never be commit automatically,

of course also wont show dirty in `git`.

## Example

Assuming that a **new file** in you project like:

```js
import path from 'path'

const getFile = () => {
const name = 'foo'
const file = path.join(__dirname, name)
console.log('TCL: getFile() -> name:', file)
return file
}
```

and with installed [**dont-care-log**](https://www.npmjs.com/package/dont-care-log), you will only see this output below on **`git status/add/diff`** commands

```diff
+ import path from 'path'
+
+ const getFile = () => {
+ const name = 'foo'
+ const file = path.join(__dirname, name)
+ return file
+ }
```

Amazing, there is no line of `console.log('TCL: ...)`

## Install

```bash
npm i -D dont-care-log
```

and [**Turbo Console Log**](https://marketplace.visualstudio.com/items?itemName=ChakrounAnas.turbo-console-log) for VSCode

## How it works

[**dont-care-log**](https://www.npmjs.com/package/dont-care-log) only teach git to ignore the specific format line which is prefixed with any spaces and `console.log('TCL:` (default format of [**Turbo Console Log**](https://marketplace.visualstudio.com/items?itemName=ChakrounAnas.turbo-console-log)).

Well, here defined a **`filter.clean`** pipe to drop the specific line (generated by Turbo-Console-Log),

and some `preinstall` hook to setup `.gitconfig` and `.gitattributes`.

More details of `git add/staging` workflow see: [> git-scm staging](https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion)

In simple terms, `filter.clean` for **staging**, `filter.smudge` **for checkout**

![filter-clean](./images/filter-clean.png)

![filter-smudge](./images/filter-smudge.png)

## Next

- [ ] multiline for per log functions
- [ ] configurable
- [ ] static parse current line to find out all variables
- [ ] log plugin of webstorm

## License

[MIT LICENSE](./LICENSE)