Niklas
Niklas
NNuxt
Created by Niklas on 3/14/2024 in #❓・help
How to hook into the nuxt consola instance
I created a custom Reporter for consola which I want to use in my nuxt projects. I tried setting up a module and a nitro plugin but I only get output from my own consola calls. I also want the errors of my app to be logged. If I am not mistaken importing consola will give me an global instance. And I did dig a little through the nuxt source code and I see that it is using the global consola instance as well. But I do not get nuxt logs at all. I tried it with a moduke like this:
import { defineNuxtModule } from "@nuxt/kit";
import { consola } from "consola";
import { LokiReporter, LokiOptions } from "consola-loki"; // my custom reporter

export default defineNuxtModule<LokiOptions>({
meta: {
name: "loki",
},
setup(options, nuxt) {
const loki = new LokiReporter(options);
consola.addReporter(loki);

consola.log('test') // this will get logged in my custom reporter
},
});
import { defineNuxtModule } from "@nuxt/kit";
import { consola } from "consola";
import { LokiReporter, LokiOptions } from "consola-loki"; // my custom reporter

export default defineNuxtModule<LokiOptions>({
meta: {
name: "loki",
},
setup(options, nuxt) {
const loki = new LokiReporter(options);
consola.addReporter(loki);

consola.log('test') // this will get logged in my custom reporter
},
});
2 replies
NNuxt
Created by Niklas on 7/12/2023 in #❓・help
useAsyncData typings when using route params
No description
1 replies