Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Effect, Option, LogLevel, Layer, References } from 'effect'; |
| 2 | import { APP_CONFIG } from 'src/config'; |
| 3 | |
| 4 | /** |
| 5 | * Sets the minimum log level for subsequent logging operations: the `--log-level` CLI flag |
| 6 | * wins when present, otherwise the level read from the config (`COMPOSIO_LOG_LEVEL`) applies, |
| 7 | * otherwise `Info`. |
| 8 | */ |
| 9 | export const setMinimumLogLevel = (logLevelFromCLI: Option.Option<LogLevel.LogLevel>) => |
| 10 | APP_CONFIG.LOG_LEVEL.pipe( |
| 11 | Effect.map((logLevelFromEnv): LogLevel.LogLevel => |
| 12 | Option.getOrElse(logLevelFromCLI, () => logLevelFromEnv ?? 'Info') |
| 13 | ), |
| 14 | Effect.map(logLevel => Layer.succeed(References.MinimumLogLevel, logLevel)), |
| 15 | Layer.unwrap |
| 16 | ); |
| 17 | |
| 18 | /** The `COMPOSIO_LOG_LEVEL` level alone, for layers built before the root command parses flags. */ |
| 19 | export const LogLevelFromConfigLive = setMinimumLogLevel(Option.none()); |