diff --git a/README.md b/README.md index d6560a9..fcd86c2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/raw.ts b/examples/raw.ts new file mode 100644 index 0000000..16d11a8 --- /dev/null +++ b/examples/raw.ts @@ -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" }); +``;