Skip to content

Commit 08216c6

Browse files
Merge pull request #2873 from AI-Hypercomputer:nicogrande/improve-max-logging
PiperOrigin-RevId: 848356647
2 parents 9a64e2f + 1a19a7b commit 08216c6

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)