Skip to content

Commit

Permalink
fix: wire up onLog() & setLogLevel() for VertexAI
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Jan 21, 2025
1 parent 185ac48 commit f699ea9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/app/lib/internal/registry/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import FirebaseApp from '../../FirebaseApp';
import { DEFAULT_APP_NAME } from '../constants';
import { setReactNativeAsyncStorageInternal } from '../asyncStorage';
import { getAppModule } from './nativeModule';
import { setLogLevel as setLogLevelInternal } from '../logger';

const APP_REGISTRY = {};
let onAppCreateFn = null;
Expand Down Expand Up @@ -203,6 +204,8 @@ export function setLogLevel(logLevel) {
if (!['error', 'warn', 'info', 'debug', 'verbose'].includes(logLevel)) {
throw new Error('LogLevel must be one of "error", "warn", "info", "debug", "verbose"');
}
// This is setting LogLevel for VertexAI which does not wrap around native SDK
setLogLevelInternal(logLevel);

if (isIOS || isOther) {
getAppModule().setLogLevel(logLevel);
Expand Down
13 changes: 8 additions & 5 deletions packages/app/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {
initializeApp as initializeAppCompat,
setLogLevel as setLogLevelCompat,
} from '../internal';
import { setUserLogHandler } from '../internal/logger';

/**
* @typedef {import('..').ReactNativeFirebase.FirebaseApp} FirebaseApp
* @typedef {import('..').ReactNativeFirebase.FirebaseAppOptions} FirebaseAppOptions
* @typedef {import('..').ReactNativeFirebase.LogLevelString} LogLevelString
* @typedef {import('../internal/logger').LogCallback} LogCallback
* @typedef {import('../internal/logger').LogOptions} LogOptions
*/

/**
Expand All @@ -34,13 +37,13 @@ export function registerVersion(libraryKeyOrName, version, variant) {
}

/**
* Sets log handler for all Firebase SDKs.
* @param {Function} logCallback - The callback function to handle logs.
* @param {Object} [options] - Optional settings for log handling.
* @returns {Promise<void>}
* Sets log handler for VertexAI only currently.
* @param {LogCallback | null} logCallback - The callback function to handle logs.
* @param {LogOptions} [options] - Optional settings for log handling.
* @returns {void}
*/
export function onLog(logCallback, options) {
throw new Error('onLog is only supported on Web');
setUserLogHandler(logCallback, options);
}

/**
Expand Down

0 comments on commit f699ea9

Please sign in to comment.