Skip to content

Commit

Permalink
update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
pavjacko committed Mar 12, 2024
1 parent 8a88f74 commit 01d9643
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/app-harness/src/app/index.tsx
Expand Up @@ -39,7 +39,7 @@ const AppContent = () => {
const handleRequestPermissions = async () => {
try {
const permission = await requestPermissions();
logDebug(`Permissions: ${permission}`);
logDebug('Permissions:', permission);
} catch (error) {
logDebug(`${error}`);
}
Expand Down Expand Up @@ -119,11 +119,11 @@ const AppContent = () => {
paddingBottom: 10,
}}
>
<Text style={styles.dynamicText}>{`Logs: `}</Text>
<Text style={[styles.dynamicText, { fontWeight: 'bold' }]}>{`Logs: `}</Text>
{logs
? logs.map((it, idx) => (
<Text key={idx} style={styles.dynamicText}>
{`${idx + 1}. ${it}`}
{it}
</Text>
))
: null}
Expand Down
7 changes: 4 additions & 3 deletions packages/app-harness/src/context/index.tsx
Expand Up @@ -4,7 +4,7 @@ type LogMessage = string;

type LoggerContextType = {
logs: LogMessage[];
logDebug: (msg: LogMessage) => void;
logDebug: (...msg: LogMessage[]) => void;
};
type LoggerProviderProps = {
children: ReactNode;
Expand All @@ -14,8 +14,9 @@ const LoggerContext = createContext<LoggerContextType>({} as LoggerContextType);

export const LoggerProvider: FC<LoggerProviderProps> = ({ children }) => {
const [logs, setLogs] = useState<LogMessage[]>([]);
const logDebug = (msg: LogMessage) => {
setLogs((prevLogs) => [...prevLogs, msg]);
const logDebug = (...msg: LogMessage[]) => {
setLogs((prevLogs) => prevLogs.concat(msg));
console.log(...msg);

Check warning on line 19 in packages/app-harness/src/context/index.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement
};

return <LoggerContext.Provider value={{ logs, logDebug }}>{children}</LoggerContext.Provider>;
Expand Down

0 comments on commit 01d9643

Please sign in to comment.