Skip to content

Commit

Permalink
docs: add note about raw method (#271)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pooya@pi0.io>
  • Loading branch information
edimitchel and pi0 authored Jun 8, 2024
1 parent 2dd21e3 commit 8062a4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,20 @@ import {
const { stripAnsi } = require("consola/utils");
```

## Raw logging methods

Objects sent to the reporter could lead to unexpected output when object is close to internal object structure containing either `message` or `args` props. To enforce the object to be interpreted as pure object, you can use the `raw` method chained to any log type.

**Example:**

```js
// Prints "hello"
consola.log({ message: "hello" });

// Prints "{ message: 'hello' }"
consola.log.raw({ message: "hello" });
```

## License

MIT
Expand Down
10 changes: 10 additions & 0 deletions examples/raw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { consola } from "./utils";

consola.log('consola.log({ message: "hello" })');
// Prints "hello"
consola.log({ message: "hello" });

consola.log('consola.log.raw({ message: "hello" })');
// Prints "{ message: 'hello' }"
consola.log.raw({ message: "hello" });
``;

0 comments on commit 8062a4f

Please sign in to comment.