mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 23:21:41 +01:00
24 lines
618 B
TypeScript
24 lines
618 B
TypeScript
import { Container } from "@/models/Container";
|
|
|
|
type LogContext = {
|
|
streamConfig: { stdout: boolean; stderr: boolean };
|
|
containers: Ref<Container[]>;
|
|
};
|
|
|
|
export const loggingContextKey = Symbol("loggingContext") as InjectionKey<LogContext>;
|
|
|
|
export const provideLoggingContext = (containers: Ref<Container[]>) => {
|
|
provide(loggingContextKey, {
|
|
streamConfig: reactive({ stdout: true, stderr: true }),
|
|
containers,
|
|
});
|
|
};
|
|
|
|
export const useLoggingContext = () => {
|
|
const context = inject(loggingContextKey);
|
|
if (!context) {
|
|
throw new Error("No logging context provided");
|
|
}
|
|
return context;
|
|
};
|