Logging: don't emit ANSI color codes if !isatty()
This CL makes a bunch of changes to logging:
- Move the core logic to a dedicated .cc file
- Add a timestamp in front of the logs (wall time % 1000)
to better debug across processe (not in the logcat case)s.
- Enables the coloured output only when stderr is a tty.
- Fixes the truncation of the filename to be left-truncated
rather than right-truncated (which is more useful in general).
Bug: 145150184
Change-Id: Idd7864057ed9411cea0da94ffb7ef520c21bef4f
diff --git a/BUILD b/BUILD
index 4d81a97..3b8cfc5 100644
--- a/BUILD
+++ b/BUILD
@@ -465,6 +465,7 @@
srcs = [
"src/base/event_fd.cc",
"src/base/file_utils.cc",
+ "src/base/logging.cc",
"src/base/metatrace.cc",
"src/base/paged_memory.cc",
"src/base/pipe.cc",