Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Implement SQLite error logging #6291

Merged
merged 1 commit into from
Sep 8, 2016
Merged

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Sep 8, 2016

Implements SQLite error logging in a very verbose fashion — for now, everything gets logged. As we see what comes down the tube, we can selectively silence common or irrelevant messages.

Notes

  • sqlite3_config() must be called before the database is initialized (which happens automatically via sqlite3_open_v2()).
  • I’m very unconfident about my type choices, would appreciate feedback.

Fixes #6267.

/cc @jfirebaugh @kkaefer @tobrun

@friedbunny friedbunny added the Core The cross-platform C++ core, aka mbgl label Sep 8, 2016
@friedbunny friedbunny self-assigned this Sep 8, 2016
@mention-bot
Copy link

@friedbunny, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh and @artemp to be potential reviewers.

@friedbunny
Copy link
Contributor Author

Clang-tidy failed:

Caught clang-tidy warning/error:
platform/default/sqlite3.cpp:61:39: warning: unused parameter 'arg' [clang-diagnostic-unused-parameter]
void Database::errorLogCallback(void *arg, const int err, const char *msg) {

... which is legit, because arg is unused. This is because we pass nullptr for the custom user data parameter:

The third argument to the sqlite3_config(SQLITE_CONFIG_LOG,...) interface (the "pData" argument in the example above) is a pointer to arbitrary data. SQLite passes this pointer through to the first argument of the error logger callback. The pointer can be used to pass application-specific setup or state information, if desired. Or it can simply be a NULL pointer which is ignored by the callback.

What’s our preferred way of dealing with unused parameters?

@friedbunny
Copy link
Contributor Author

Here’s the only message I’ve seen so far, as an example of the output:

[INFO] {DefaultFileSource}[Database]: recovered 211 frames from WAL file /Library/Developer/CoreSimulator/.../com.mapbox.MapboxGL/.mapbox/cache.db-wal (Code 283)

This message seems to come every time the database is started (i.e., on app launch).

More on SQLite result codes here — 283 is SQLITE_NOTICE_RECOVER_WAL.

@jfirebaugh
Copy link
Contributor

What’s our preferred way of dealing with unused parameters?

Omit the argument name: void Database::errorLogCallback(void *, const int err, const char *msg).

LGTM. This should help immensely.

@friedbunny friedbunny force-pushed the fb-sqlite-error-logging branch from c7410bd to 2ed98b2 Compare September 8, 2016 16:38
@friedbunny
Copy link
Contributor Author

Thanks @jfirebaugh, I’ve removed the argument name and pushed a rebased branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants