A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: use sqlite based logger
Ammar Ahmedeab5bccb99a4
diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsxindex 501b875c5..5329b3bbc 100644--- a/apps/mobile/app/app.tsx+++ b/apps/mobile/app/app.tsx@@ -16,15 +16,16 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import "react-native-gesture-handler";import {THEME_COMPATIBILITY_VERSION,useThemeEngineStore} from "@notesnook/theme";import React, { useEffect } from "react";import { I18nManager, View } from "react-native";+import "react-native-gesture-handler";import { GestureHandlerRootView } from "react-native-gesture-handler";import { SafeAreaProvider } from "react-native-safe-area-context";+import { initializeLogger } from "./common/database/logger";import AppLockedOverlay from "./components/app-lock-overlay";import { withErrorBoundry } from "./components/exception-handler";import GlobalSafeAreaProvider from "./components/globalsafearea";@@ -44,23 +45,28 @@ I18nManager.swapLeftAndRightInRTL(false);const App = () => {const init = useAppEvents();useEffect(() => {- const { appLockEnabled, appLockMode } = SettingsService.get();- if (appLockEnabled || appLockMode !== "none") {- useUserStore.getState().lockApp(true);- }-- //@ts-ignore- globalThis["IS_MAIN_APP_RUNNING"] = true;- init();- setTimeout(async () => {- SettingsService.onFirstLaunch();- await Notifications.get();- if (SettingsService.get().notifNotes) {- Notifications.pinQuickNote(true);- }- TipManager.init();- }, 100);-+ initializeLogger()+ .catch((e) => {+ console.log(e);+ })+ .finally(() => {+ const { appLockEnabled, appLockMode } = SettingsService.get();+ if (appLockEnabled || appLockMode !== "none") {+ useUserStore.getState().lockApp(true);+ }++ //@ts-ignore+ globalThis["IS_MAIN_APP_RUNNING"] = true;+ init();+ setTimeout(async () => {+ SettingsService.onFirstLaunch();+ await Notifications.get();+ if (SettingsService.get().notifNotes) {+ Notifications.pinQuickNote(true);+ }+ TipManager.init();+ }, 100);+ });// eslint-disable-next-line react-hooks/exhaustive-deps}, []);diff --git a/apps/mobile/app/common/database/index.js b/apps/mobile/app/common/database/index.jsindex 434943a36..375934bd7 100644--- a/apps/mobile/app/common/database/index.js+++ b/apps/mobile/app/common/database/index.js@@ -85,4 +85,10 @@ export async function setupDatabase(password) {}export const db = database;-export const DatabaseLogger = dbLogger;+let DatabaseLogger = dbLogger.scope(Platform.OS);++const setLogger = () => {+ DatabaseLogger = dbLogger.scope(Platform.OS);+};++export { DatabaseLogger, setLogger };diff --git a/apps/mobile/app/common/database/logger.js b/apps/mobile/app/common/database/logger.jsindex aed3bfa5e..2a86a163f 100644--- a/apps/mobile/app/common/database/logger.js+++ b/apps/mobile/app/common/database/logger.js@@ -16,14 +16,27 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { MMKVLoader } from "react-native-mmkv-storage";-import { initialize } from "@notesnook/core/dist/logger";-import { KV } from "./storage";-const LoggerStorage = new MMKVLoader()- .withInstanceID("notesnook_logs")- .initialize();+import { initialize } from "@notesnook/core/dist/logger";+import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";+import { Platform } from "react-native";+import { setLogger } from ".";+import { RNSqliteDriver } from "./sqlite.kysely";-initialize(new KV(LoggerStorage));+const initializeLogger = async () => {+ await initialize({+ dialect: (name) => ({+ createDriver: () => {+ return new RNSqliteDriver({ async: true, dbName: name });+ },+ createAdapter: () => new SqliteAdapter(),+ createIntrospector: (db) => new SqliteIntrospector(db),+ createQueryCompiler: () => new SqliteQueryCompiler()+ }),+ tempStore: "memory",+ journalMode: Platform.OS === "ios" ? "DELETE" : "WAL"+ });+ setLogger();+};-export { LoggerStorage };+export { initializeLogger };diff --git a/apps/mobile/app/screens/settings/debug.tsx b/apps/mobile/app/screens/settings/debug.tsxindex e709a8795..23a438d7e 100644--- a/apps/mobile/app/screens/settings/debug.tsx+++ b/apps/mobile/app/screens/settings/debug.tsx@@ -122,7 +122,8 @@ export default function DebugLogs() {colors.primary.paragraph,colors.error.paragraph,colors.static.black,- colors.static.orange+ colors.static.orange,+ colors.primary.border]);