1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-26 23:21:41 +01:00
Files
dozzle/assets/composable/logContext.ts
2024-07-22 20:57:27 +00:00

29 lines
690 B
TypeScript

import { Container } from "@/models/Container";
type LogContext = {
streamConfig: { stdout: boolean; stderr: boolean };
containers: Container[];
loadingMore: boolean;
};
export const loggingContextKey = Symbol("loggingContext") as InjectionKey<LogContext>;
export const provideLoggingContext = (containers: Ref<Container[]>) => {
provide(
loggingContextKey,
reactive({
streamConfig: { stdout: true, stderr: true },
containers,
loadingMore: false,
}),
);
};
export const useLoggingContext = () => {
const context = inject(loggingContextKey);
if (!context) {
throw new Error("No logging context provided");
}
return toRefs(context);
};