mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 23:21:41 +01:00
29 lines
690 B
TypeScript
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);
|
|
};
|