Skip to content

Warning written to log on every Database open regardless of status of File Log Sinks #25

@andrew-charles

Description

@andrew-charles

Every time I open a database, I get this log message, no matter what I have set for File based logging:

W Database.log.getFile().getConfig() is now null: logging is disabled. Log files required for product support are not being generated.

This message is outright wrong in this case, as it's not null, but apparently there's a bug in the code and no matter what you'll get this message:

private void warnIfNoFileLogSink() {
        final FileLogSink sink = fileLogSink;
        if ((sink != null) && (sink.getLevel() != LogLevel.NONE) && !warned.getAndSet(true)) { return; }
        ((AbstractLogSink) new ConsoleLogSink(LogLevel.WARNING, LogDomain.DATABASE)).writeLog(
            LogLevel.WARNING,
            LogDomain.DATABASE,
            "Database.log.getFile().getConfig() is now null: logging is disabled.  "
                + "Log files required for product support are not being generated.");
    }

I have several issues with this code besides this.

  1. If I want to disable File based logging, I should be able to do it, and not get complaints about it. If there has to be a warning, it should be on init(), not every single time I attempt to open a DB. The older version of couchbase lite mobile (2.x) did not have this issue.
  2. This code here creates an arbitrary console logger (which in android writes to Logcat), so there's no way to suppress it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions