Skip to content

Commit 876e563

Browse files
committed
Make logger respect --ignore-warnings
1 parent 5b2fa5b commit 876e563

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

sqlmesh/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def configure_logging(
172172
write_to_file: bool = True,
173173
log_limit: int = c.DEFAULT_LOG_LIMIT,
174174
log_file_dir: t.Optional[t.Union[str, Path]] = None,
175+
ignore_warnings: bool = False,
175176
) -> None:
176177
# Remove noisy grpc logs that are not useful for users
177178
os.environ["GRPC_VERBOSITY"] = os.environ.get("GRPC_VERBOSITY", "NONE")
@@ -186,7 +187,7 @@ def configure_logging(
186187
if write_to_stdout:
187188
stdout_handler = logging.StreamHandler(sys.stdout)
188189
stdout_handler.setFormatter(CustomFormatter())
189-
stdout_handler.setLevel(level)
190+
stdout_handler.setLevel(logging.ERROR if ignore_warnings else level)
190191
logger.addHandler(stdout_handler)
191192

192193
log_file_dir = log_file_dir or c.DEFAULT_LOG_FILE_DIR

sqlmesh/cli/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ def cli(
102102

103103
configs = load_configs(config, Context.CONFIG_TYPE, paths)
104104
log_limit = list(configs.values())[0].log_limit
105-
configure_logging(debug, log_to_stdout, log_limit=log_limit, log_file_dir=log_file_dir)
105+
configure_logging(
106+
debug,
107+
log_to_stdout,
108+
log_limit=log_limit,
109+
log_file_dir=log_file_dir,
110+
ignore_warnings=ignore_warnings,
111+
)
106112
configure_console(ignore_warnings=ignore_warnings)
107113

108114
try:

sqlmesh/magics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def context(self, line: str) -> None:
134134
args = parse_argstring(self.context, line)
135135
configs = load_configs(args.config, Context.CONFIG_TYPE, args.paths)
136136
log_limit = list(configs.values())[0].log_limit
137-
configure_logging(args.debug, log_limit=log_limit, log_file_dir=args.log_file_dir)
137+
configure_logging(
138+
args.debug,
139+
log_limit=log_limit,
140+
log_file_dir=args.log_file_dir,
141+
ignore_warnings=args.ignore_warnings,
142+
)
138143
configure_console(ignore_warnings=args.ignore_warnings)
139144
try:
140145
context = Context(paths=args.paths, config=configs, gateway=args.gateway)

0 commit comments

Comments
 (0)