logtape
logtape copied to clipboard
`logtape·meta` logs unexpectedly
Hi,
If you are seeing this message, the meta logger is somehow configured.
I don't see how I'm configuring meta logger in this example I derived from the documentation.
Am I doing something wrong? Thanks.
Latest version from npm. Happy to provide more details as needed.
import { configure, getConsoleSink, getLogger } from "@logtape/logtape"
await configure({
sinks: { console: getConsoleSink() },
loggers: [
{
category: "my-app",
level: "info",
sinks: ["console"],
},
],
})
const logger = getLogger(["my-app"])
logger.info("foo")
> tsx main.ts
10:51:57.989 INF logtape·meta LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category [ 'logtape', 'meta', [length]: 2 ]. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is somehow configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than 'info'.
10:51:57.990 INF my-app foo
To turn off this message, configure the meta logger with higher log levels than 'info'.
You can suppress it by configuring the meta logger with a higher log level than "info":
await configure({
sinks: { console: getConsoleSink() },
loggers: [
{
category: ["logtape", "meta"],
level: "warning",
sinks: ["console"],
},
{
category: "my-app",
level: "info",
sinks: ["console"],
},
],
});
Thanks for the reply, I appreciate it.
However I find this unintuitive and not a great first impression.
The log message says:
If you are seeing this message, the meta logger is somehow configured.
This implies I have somehow configured it by mistake, and that it's not a default behavior of the library (which it seems to be?).
Additionally, why do the internals of this logging library log something by default? This is not a behavior I've ever seen with other logging libraries and comes off as a bug.
If you are seeing this message, the meta logger is somehow configured.
This implies I have somehow configured it by mistake, and that it's not a default behavior of the library (which it seems to be?).
Indeed that's misleading. It's probably because English is not my first language. I'll adjust the message.
Additionally, why do the internals of this logging library log something by default? This is not a behavior I've ever seen with other logging libraries and comes off as a bug.
As sometimes a sink can fail to record a log message, I think such meta logs should be recorded and shown to users. 🤔
Understood, thanks again.
For what it's worth, given the earlier example, I think the least surprising outcome is to see just:
10:51:57.990 INF my-app foo
If I'm setting up a logger, especially a library I'm not that familiar with, I would like there to be minimal noise & mental overhead and not have to worry about how to hide the internal meta logs or what they mean.
Just my 2c 🙏
I'm trying out the library and ran across this as well. Wasn't straight forward to find out how to disable the meta logger. Maybe this can be included in the quick start docs? Right now it is in the last section under "categories" - https://logtape.org/manual/categories#meta-logger
Personally, I think the meta logger should be disabled by default with an option to enable it when we call configure.