Comparing version
@@ -0,1 +1,13 @@ | ||
<a name="3.2.0"></a> | ||
# 3.2.0 (2017-04-14) | ||
* Add %J formatter ([4192659](https://github.com/achohq/acho/commit/4192659)) | ||
* Refactor formatter ([99585a6](https://github.com/achohq/acho/commit/99585a6)) | ||
* Update deps ([e5283d7](https://github.com/achohq/acho/commit/e5283d7)) | ||
* Update README.md ([b325807](https://github.com/achohq/acho/commit/b325807)) | ||
* Update travis builds ([77a2452](https://github.com/achohq/acho/commit/77a2452)) | ||
* chore(package): update dependencies ([76eb538](https://github.com/achohq/acho/commit/76eb538)) | ||
<a name="3.1.2"></a> | ||
@@ -2,0 +14,0 @@ ## 3.1.2 (2017-03-03) |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/achohq/acho", | ||
"version": "3.1.2", | ||
"version": "3.2.0", | ||
"main": "./index.js", | ||
@@ -30,4 +30,6 @@ "author": { | ||
"chalk": "~1.1.1", | ||
"coffee-script": "~1.11.0", | ||
"pretty-ms": "~2.1.0" | ||
"coffee-script": "~1.12.4", | ||
"fmt-obj": "~1.3.0", | ||
"pretty-ms": "~2.1.0", | ||
"sliced": "~1.0.1" | ||
}, | ||
@@ -34,0 +36,0 @@ "devDependencies": { |
@@ -162,2 +162,4 @@ # acho | ||
See more at [examples/levels](https://github.com/achohq/acho/blob/master/examples/levels.js). | ||
### Customization | ||
@@ -199,2 +201,48 @@ | ||
## Formatters | ||
We use [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Below are the officially supported formatters: | ||
| Formatter | Representation | | ||
|-----------|---------------------------------------------------------------| | ||
| `%s` | String. | | ||
| `%d` | Number (both integer and float). | | ||
| `%j` | JSON serialization in one line | | ||
| `%J` | JSON pretty object in multiple lines | | ||
| `%%` | Single percent sign ('%'). This does not consume an argument. | | ||
By default, the `%j` is applied when you pass an object to be logged: | ||
```js | ||
acho.info({hello: 'world', foo: 'bar'}) | ||
// => 'info hello=world foo=bar' | ||
``` | ||
If you want to use a different formatter, use printf markup: | ||
```js | ||
acho.info('formatting with object interpolation %J', { | ||
hello: 'world', | ||
foo: 'bar', | ||
deep: { | ||
foo: 'bar', | ||
arr: [1, 2, 3, 4, 5] | ||
} | ||
}) | ||
// info formatting with object interpolation | ||
// hello: "world" | ||
// foo: "bar" | ||
// deep: | ||
// foo: "bar" | ||
// arr: | ||
// 0: 1 | ||
// 1: 2 | ||
// 2: 3 | ||
// 3: 4 | ||
// 4: 5 | ||
``` | ||
See more at [examples/formatter](https://github.com/achohq/acho/blob/master/examples/formatter.js). | ||
## API | ||
@@ -220,3 +268,3 @@ | ||
Default: ` ` | ||
Default: `' '` | ||
@@ -223,0 +271,0 @@ It adds an alignment separator between the type of the message and the message. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39675
7.06%361
15.34%5
66.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
Updated