Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logtape·meta logs unexpectedly #23

Open
raine opened this issue Oct 10, 2024 · 5 comments
Open

logtape·meta logs unexpectedly #23

raine opened this issue Oct 10, 2024 · 5 comments

Comments

@raine
Copy link

raine commented Oct 10, 2024

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
@raine raine changed the title logtape·meta meta logs unexpectedly logtape·meta logs unexpectedly Oct 10, 2024
@dahlia
Copy link
Owner

dahlia commented Oct 10, 2024

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"],
    },
  ],
});

@raine
Copy link
Author

raine commented Oct 10, 2024

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.

@dahlia
Copy link
Owner

dahlia commented Oct 11, 2024

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. 🤔

@raine
Copy link
Author

raine commented Oct 11, 2024

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 🙏

@w3cj
Copy link

w3cj commented Oct 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants