Skip to content

feat: Logger API/Helpers #570

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: Logger API/Helpers #570

wants to merge 3 commits into from

Conversation

Chriztiaan
Copy link
Contributor

@Chriztiaan Chriztiaan commented Apr 17, 2025

A common pain point for logging is that users need to depend on js-logger to manage the logging for PowerSync.
This wraps and exports the logging as a simple utility available from common, web, and react-native - baking js-logger into the packages.

To ensure consumers of the web package no won't need the vite config for js-logger, js-logger is now bundled in common. This adds 3KB to the final web bundle.

This bundling work, and the vite config not being needed, have been verified via a dev release of this branch.

Will remove js-logger from the demos/tools, and update the packages in the next PR.

Example usage:

import { createBaseLogger, createLogger, LogLevel, PowerSyncDatabase } from '@powersync/web';

const defaultLogger = createBaseLogger();
defaultLogger.useDefaults();
defaultLogger.setLevel(LogLevels.OFF);

const myLogger = createLogger("my-little-logger");
myLogger.setLevel(LogLevels.ERROR);

export const db = new PowerSyncDatabase({
  schema: AppSchema,
  database: {
    dbFilename: 'example.db'
  },
  logger: myLogger,
});

Copy link

changeset-bot bot commented Apr 17, 2025

🦋 Changeset detected

Latest commit: b4fc8a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@powersync/web Minor
@powersync/common Minor
@powersync/diagnostics-app Patch
@powersync/node Patch
@powersync/op-sqlite Patch
@powersync/react-native Patch
@powersync/tanstack-react-query Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Chriztiaan Chriztiaan marked this pull request as ready for review April 17, 2025 10:09
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

Successfully merging this pull request may close these issues.

1 participant