Skip to content

Commit 1a19a7b

Browse files
committed
Improve max logging to use absl logging.
1 parent b2b7d8f commit 1a19a7b

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/MaxText/max_logging.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,31 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Stub for logging utilities. Right now just meant to avoid raw prints."""
15+
"""Logging utilities."""
16+
from absl import logging
1617

1718

1819
def log(user_str):
19-
print(user_str, flush=True)
20+
"""Logs a message at the INFO level."""
21+
# Note, stacklevel=2 makes the log show the caller of this function.
22+
logging.info(user_str, stacklevel=2)
23+
24+
25+
def debug(user_str):
26+
"""Logs a message at the DEBUG level."""
27+
logging.debug(user_str, stacklevel=2)
28+
29+
30+
def info(user_str):
31+
"""Logs a message at the INFO level."""
32+
logging.info(user_str, stacklevel=2)
33+
34+
35+
def warning(user_str):
36+
"""Logs a message at the WARNING level."""
37+
logging.warning(user_str, stacklevel=2)
38+
39+
40+
def error(user_str):
41+
"""Logs a message at the ERROR level."""
42+
logging.error(user_str, stacklevel=2)

0 commit comments

Comments
 (0)