forked from Ninjalama/streamyfin_mirror
feat: expo env variables & export logs
This commit is contained in:
1
.env.development
Normal file
1
.env.development
Normal file
@@ -0,0 +1 @@
|
||||
EXPO_PUBLIC_WRITE_DEBUG=1
|
||||
1
.env.production
Normal file
1
.env.production
Normal file
@@ -0,0 +1 @@
|
||||
EXPO_PUBLIC_WRITE_DEBUG=0
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -46,4 +46,5 @@ credentials.json
|
||||
.ruby-lsp
|
||||
modules/hls-downloader/android/build
|
||||
streamyfin-4fec1-firebase-adminsdk.json
|
||||
.env
|
||||
.env
|
||||
.env.local
|
||||
@@ -1,12 +1,17 @@
|
||||
import { Text } from "@/components/common/Text";
|
||||
import {LogLevel, useLog} from "@/utils/log";
|
||||
import {LogLevel, useLog, writeErrorLog} from "@/utils/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {ScrollView, TouchableOpacity, View} from "react-native";
|
||||
import Collapsible from "react-native-collapsible";
|
||||
import React, {useMemo, useState} from "react";
|
||||
import React, {useCallback, useEffect, useMemo, useState} from "react";
|
||||
import {FilterButton} from "@/components/filters/FilterButton";
|
||||
import {useNavigation} from "expo-router";
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import {Loader} from "@/components/Loader";
|
||||
|
||||
export default function page() {
|
||||
const navigation = useNavigation();
|
||||
const { logs } = useLog();
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -18,6 +23,7 @@ export default function page() {
|
||||
maxHeight: 300
|
||||
}
|
||||
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const [state, setState] = useState<Record<string, boolean>>({})
|
||||
|
||||
const [order, setOrder] = useState<"asc" | "desc">("desc");
|
||||
@@ -31,6 +37,34 @@ export default function page() {
|
||||
[logs, order, levels]
|
||||
)
|
||||
|
||||
// Sharing it as txt while its formatted allows us to share it with many more applications
|
||||
const share = useCallback(async () => {
|
||||
const uri = FileSystem.documentDirectory + "logs.txt"
|
||||
|
||||
setLoading(true)
|
||||
FileSystem.writeAsStringAsync(uri, JSON.stringify(filteredLogs))
|
||||
.then(() => {
|
||||
setLoading(false)
|
||||
Sharing.shareAsync(uri, {mimeType: "txt", UTI: "txt"})
|
||||
})
|
||||
.catch((e) => writeErrorLog("Something went wrong attempting to export", e))
|
||||
.finally(() => setLoading(false))
|
||||
}, [filteredLogs])
|
||||
|
||||
useEffect(() => {
|
||||
navigation.setOptions({
|
||||
headerRight: () => (
|
||||
loading
|
||||
? <Loader/>
|
||||
: (
|
||||
<TouchableOpacity onPress={share}>
|
||||
<Text>Export</Text>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
),
|
||||
});
|
||||
}, [share, loading]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className="flex flex-row justify-end py-2 px-4 space-x-2">
|
||||
@@ -86,7 +120,9 @@ export default function page() {
|
||||
|
||||
{log.data && (
|
||||
<>
|
||||
<Text className="text-xs">{t("home.settings.logs.click_for_more_info")}</Text>
|
||||
{!state[log.timestamp] && (
|
||||
<Text className="text-xs mt-0.5">{t("home.settings.logs.click_for_more_info")}</Text>
|
||||
)}
|
||||
<Collapsible collapsed={!state[log.timestamp]}>
|
||||
<View className="mt-2 flex flex-col space-y-2">
|
||||
<ScrollView className="rounded-xl" style={codeBlockStyle}>
|
||||
|
||||
3
bun.lock
3
bun.lock
@@ -44,6 +44,7 @@
|
||||
"expo-router": "~4.0.17",
|
||||
"expo-screen-orientation": "~8.0.4",
|
||||
"expo-sensors": "~14.0.2",
|
||||
"expo-sharing": "~13.0.1",
|
||||
"expo-splash-screen": "~0.29.22",
|
||||
"expo-status-bar": "~2.0.1",
|
||||
"expo-system-ui": "~4.0.8",
|
||||
@@ -1201,6 +1202,8 @@
|
||||
|
||||
"expo-sensors": ["expo-sensors@14.0.2", "", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "expo": "*", "react-native": "*" } }, "sha512-nCb1Q3ctb0oVTZ9p6eFmQ2fINa6KoxXXIhagPpdN0qR82p00YosP27IuyxjVB3fnCJFeC4TffNxNjBxwAUk+nA=="],
|
||||
|
||||
"expo-sharing": ["expo-sharing@13.0.1", "", { "peerDependencies": { "expo": "*" } }, "sha512-qych3Nw65wlFcnzE/gRrsdtvmdV0uF4U4qVMZBJYPG90vYyWh2QM9rp1gVu0KWOBc7N8CC2dSVYn4/BXqJy6Xw=="],
|
||||
|
||||
"expo-splash-screen": ["expo-splash-screen@0.29.22", "", { "dependencies": { "@expo/prebuild-config": "^8.0.27" }, "peerDependencies": { "expo": "*" } }, "sha512-f+bPpF06bqiuW1Fbrd3nxeaSsmTVTBEKEYe3epYt4IE6y4Ulli3qEUamMLlRQiDGuIXPU6zQlscpy2mdBUI5cA=="],
|
||||
|
||||
"expo-status-bar": ["expo-status-bar@2.0.1", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-AkIPX7jWHRPp83UBZ1iXtVvyr0g+DgBVvIXTtlmPtmUsm8Vq9Bb5IGj86PW8osuFlgoTVAg7HI/+Ok7yEYwiRg=="],
|
||||
|
||||
8
eas.json
8
eas.json
@@ -11,7 +11,7 @@
|
||||
"buildType": "apk"
|
||||
},
|
||||
"env": {
|
||||
"DEBUG": "1"
|
||||
"EXPO_PUBLIC_WRITE_DEBUG": "1"
|
||||
}
|
||||
},
|
||||
"development_tv": {
|
||||
@@ -22,13 +22,13 @@
|
||||
},
|
||||
"env": {
|
||||
"EXPO_TV": "1",
|
||||
"DEBUG": "1"
|
||||
"EXPO_PUBLIC_WRITE_DEBUG": "1"
|
||||
}
|
||||
},
|
||||
"preview": {
|
||||
"distribution": "internal",
|
||||
"env": {
|
||||
"DEBUG": "1"
|
||||
"EXPO_PUBLIC_WRITE_DEBUG": "1"
|
||||
}
|
||||
},
|
||||
"development-simulator": {
|
||||
@@ -38,7 +38,7 @@
|
||||
"simulator": true
|
||||
},
|
||||
"env": {
|
||||
"DEBUG": "1"
|
||||
"EXPO_PUBLIC_WRITE_DEBUG": "1"
|
||||
}
|
||||
},
|
||||
"production": {
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
"submodule-reload": "git submodule update --init --remote --recursive",
|
||||
"clean": "echo y | expo prebuild --clean",
|
||||
"start": "bun run submodule-reload && expo start",
|
||||
"ios": "EXPO_TV=0 DEBUG=1 expo run:ios",
|
||||
"ios:tv": "EXPO_TV=1 DEBUG=1 expo run:ios",
|
||||
"android": "EXPO_TV=0 DEBUG=1 expo run:android",
|
||||
"android:tv": "EXPO_TV=1 DEBUG=1 expo run:android",
|
||||
"ios": "EXPO_TV=0 expo run:ios",
|
||||
"ios:tv": "EXPO_TV=1 expo run:ios",
|
||||
"android": "EXPO_TV=0 expo run:android",
|
||||
"android:tv": "EXPO_TV=1 expo run:android",
|
||||
"prebuild": "EXPO_TV=0 bun run clean",
|
||||
"prebuild:tv": "EXPO_TV=1 bun run clean",
|
||||
"prepare": "husky",
|
||||
@@ -56,6 +56,7 @@
|
||||
"expo-router": "~4.0.17",
|
||||
"expo-screen-orientation": "~8.0.4",
|
||||
"expo-sensors": "~14.0.2",
|
||||
"expo-sharing": "~13.0.1",
|
||||
"expo-splash-screen": "~0.29.22",
|
||||
"expo-status-bar": "~2.0.1",
|
||||
"expo-system-ui": "~4.0.8",
|
||||
|
||||
@@ -63,7 +63,7 @@ export const writeInfoLog = (message: string, data?: any) =>
|
||||
export const writeErrorLog = (message: string, data?: any) =>
|
||||
writeToLog("ERROR", message, data);
|
||||
export const writeDebugLog = (message: string, data?: any) => {
|
||||
if (process.env.DEBUG === "1") {
|
||||
if (process.env.EXPO_PUBLIC_WRITE_DEBUG === "1") {
|
||||
writeToLog("DEBUG", message, data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user