@powersync/service-core 0.0.0-dev-20260129134434 → 0.0.0-dev-20260202111439

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,28 @@
1
1
  import * as fs from 'fs/promises';
2
+ import winston from 'winston';
2
3
 
3
- import { container } from '@powersync/lib-services-framework';
4
+ import { container, logger, LogFormat, DEFAULT_LOG_LEVEL, DEFAULT_LOG_FORMAT } from '@powersync/lib-services-framework';
5
+ import { configFile } from '@powersync/service-types';
4
6
  import { ResolvedPowerSyncConfig, RunnerConfig } from './config/types.js';
5
7
  import { CompoundConfigCollector } from './util-index.js';
6
8
 
9
+ export function configureLogger(config?: configFile.LoggingConfig): void {
10
+ const level = process.env.PS_LOG_LEVEL ?? config?.level ?? DEFAULT_LOG_LEVEL;
11
+ const format = (process.env.PS_LOG_FORMAT as configFile.LoggingConfig['format']) ?? config?.format ?? DEFAULT_LOG_FORMAT;
12
+ const winstonFormat = format === 'json' ? LogFormat.production : LogFormat.development;
13
+
14
+ logger.configure({ level, format: winstonFormat, transports: [new winston.transports.Console()] });
15
+ console.log(`[PREFLIGHT] Configured logger with level "${level}" and format "${format}"`); // we want the user to always be aware that a log level was configured (they might forget they set it in the config and wonder why they aren't seeing logs)
16
+ }
17
+
7
18
  /**
8
19
  * Loads the resolved config using the registered config collector
9
20
  */
10
21
  export async function loadConfig(runnerConfig: RunnerConfig) {
11
22
  const collector = container.getImplementation(CompoundConfigCollector);
12
- return collector.collectConfig(runnerConfig);
23
+ const config = await collector.collectConfig(runnerConfig);
24
+ configureLogger(config.base_config.system?.logging);
25
+ return config;
13
26
  }
14
27
 
15
28
  export async function loadSyncRules(config: ResolvedPowerSyncConfig): Promise<string | undefined> {