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/Android.bp b/Android.bp
index b722a95..6922b3b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4047,6 +4047,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",