Reland "Gooftool: Add Testlog data to the report archive"

This reverts commit 82da96a54719de99ba5c9375c0954e0d9db2bf3c.

Reason for revert: The real fix is ready - CL:1883355.

Original change's description:
> Revert "Gooftool: Add Testlog data to the report archive"
>
> This reverts commit 2b43cc2c0916799a30ec92cd62c9327657ef4065.
>
> Reason for revert: b:143266260
>
> Original change's description:
> > Gooftool: Add Testlog data to the report archive
> >
> > Add Testlog data to the report archive. After we complete the new
> > logging system for Testlog, we can deprecate Eventlog.
> >
> > BUG=b:36868023
> > TEST=manually test on my local device
> >
> > Cq-Depend: chromium:1724231
> > Change-Id: Ie0bf49f792a82231f8d97bf9403da0b97b9d2b43
> > Reviewed-on: https://chromium-review.googlesource.com/1708390
> > Tested-by: Chun-Tsen Kuo <chuntsen@chromium.org>
> > Commit-Ready: Chun-Tsen Kuo <chuntsen@chromium.org>
> > Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
> > Reviewed-by: Wei-Han Chen <stimim@chromium.org>
> > Reviewed-by: Meng-Huan Yu <menghuan@chromium.org>
>
> Bug: b:36868023
> Change-Id: I0df1375d62c884e17efa8b50a8c3d183d5196fe9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1881369
> Tested-by: Philip Chen <philipchen@chromium.org>
> Auto-Submit: Philip Chen <philipchen@chromium.org>
> Reviewed-by: Philip Chen <philipchen@chromium.org>
> Reviewed-by: Frank Huang <frankbozar@chromium.org>
> Commit-Queue: Wei-Han Chen <stimim@chromium.org>
> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>

Bug: b:36868023
Cq-Depend: chromium:1883355
Change-Id: Iec2d4b75e2f57304a1ec8236c39b9429c91454e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1898204
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Chun-Tsen Kuo <chuntsen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index 6a821c2..b31833e 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -37,6 +37,7 @@
 from cros.factory.test import event_log
 from cros.factory.test.rules import phase
 from cros.factory.test.rules.privacy import FilterDict
+from cros.factory.test import state
 from cros.factory.utils import argparse_utils
 from cros.factory.utils.argparse_utils import CmdArg
 from cros.factory.utils.argparse_utils import ParseCmdline
@@ -591,6 +592,12 @@
   Returns:
     Path to the archive.
   """
+  # Flush Testlog data to DATA_TESTLOG_DIR before creating a report archive.
+  result, reason = state.GetInstance().FlushTestlog(
+      uplink=False, local=True, timeout=10)
+  if not result:
+    logging.warning('Failed to flush testlog data: %s', reason)
+
   def NormalizeAsFileName(token):
     return re.sub(r'\W+', '', token).strip()
 
@@ -604,6 +611,7 @@
   # Intentionally ignoring dotfiles in EVENT_LOG_DIR.
   tar_cmd = 'cd %s ; tar cJf %s *' % (event_log.EVENT_LOG_DIR, target_path)
   tar_cmd += ' %s' % paths.FACTORY_LOG_PATH
+  tar_cmd += ' %s' % paths.DATA_TESTLOG_DIR
   if add_file:
     for f in add_file:
       # Require absolute paths since the tar command may change the