Skip to content

Commit

Permalink
Fix typechecks
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderRedYT committed Nov 8, 2024
1 parent e0d6646 commit 3229581
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/logging/LogLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LogLineItem = styled(Box)<{

const LogLine = ({ log }: LogLineProps) => {
const theme = useTheme();
const color = log.options.colors[log.level.text];
const color = log.options?.colors?.[log.level.text];

return (
<LogLineItem theme={theme}>
Expand Down
21 changes: 16 additions & 5 deletions src/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import type {
transportFunctionType,
} from 'react-native-logs';
import { consoleTransport, logger } from 'react-native-logs';
import type { ConsoleTransportOptions } from 'react-native-logs/dist/transports/consoleTransport';

import { InteractionManager } from 'react-native';

import moment from 'moment';

let pushMessageFunction: transportFunctionType | null = null;
let pushMessageFunction: transportFunctionType<ConsoleTransportOptions> | null =
null;

export type LogProps = Parameters<transportFunctionType>[0] & {
export type LogProps = Parameters<
transportFunctionType<ConsoleTransportOptions>
>[0] & {
uuid: string;
};

Expand All @@ -19,11 +23,15 @@ export interface ExtendedLogProps extends LogProps {
stacktrace?: string;
}

export const setPushMessageFunction = (func: transportFunctionType) => {
export const setPushMessageFunction = (
func: transportFunctionType<ConsoleTransportOptions>,
) => {
pushMessageFunction = func;
};

const customTransport: transportFunctionType = (...args) => {
const customTransport: transportFunctionType<ConsoleTransportOptions> = (
...args
) => {
if (pushMessageFunction) pushMessageFunction(...args);
};

Expand All @@ -34,7 +42,10 @@ export enum LogLevel {
error,
}

const config: configLoggerType = {
const config: configLoggerType<
transportFunctionType<object> | transportFunctionType<object>[],
string
> = {
transport: [consoleTransport, customTransport],
severity: __DEV__ ? 'info' : 'warn',
transportOptions: {
Expand Down

0 comments on commit 3229581

Please sign in to comment.