Skip to content

Commit f0e8bda

Browse files
committed
change print statements to logs
1 parent 75a0931 commit f0e8bda

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.generator/cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _read_json_file(path):
3232

3333
def handle_configure(dry_run=False):
3434
# TODO(https://github.com/googleapis/librarian/issues/466): Implement configure command.
35-
print("'configure' command executed.")
35+
logger.info("'configure' command executed.")
3636

3737

3838
def handle_generate(dry_run=False):
@@ -42,19 +42,18 @@ def handle_generate(dry_run=False):
4242
try:
4343
request_data = _read_json_file(f"{LIBRARIAN_DIR}/{GENERATE_REQUEST_FILE}")
4444
except Exception as e:
45-
logger.error(e)
45+
logger.error(f"failed to read {LIBRARIAN_DIR}/{GENERATE_REQUEST_FILE}: {e}")
4646
sys.exit(1)
4747

48-
# Print the data:
49-
print(json.dumps(request_data, indent=2))
48+
logger.info(json.dumps(request_data, indent=2))
5049

5150
# TODO(https://github.com/googleapis/librarian/issues/448): Implement generate command.
52-
print("'generate' command executed.")
51+
logger.info("'generate' command executed.")
5352

5453

5554
def handle_build(dry_run=False):
5655
# TODO(https://github.com/googleapis/librarian/issues/450): Implement build command.
57-
print("'build' command executed.")
56+
logger.info("'build' command executed.")
5857

5958

6059
if __name__ == "__main__":

.generator/test_cli.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import pytest
1717
import json
18+
import logging
1819

1920
from unittest.mock import mock_open
2021

@@ -58,15 +59,16 @@ def test_handle_generate_dry_run():
5859
handle_generate(dry_run=True)
5960

6061

61-
def test_handle_generate_success(capsys, mock_generate_request_file):
62+
def test_handle_generate_success(caplog, mock_generate_request_file):
6263
"""
6364
Tests the successful execution path of handle_generate.
6465
"""
66+
caplog.set_level(logging.INFO)
67+
6568
handle_generate(dry_run=False)
6669

67-
captured = capsys.readouterr()
68-
assert "google-cloud-language" in captured.out
69-
assert "'generate' command executed." in captured.out
70+
assert "google-cloud-language" in caplog.text
71+
assert "'generate' command executed." in caplog.text
7072

7173

7274
def test_handle_build_dry_run():

0 commit comments

Comments
 (0)