Telemetry: use print instead of logging

Using the logging library before UTR can set it up puts it in a weird
state that consumes all output. Instead of using logging, just print
anything from initializing telemetry.

Also make some small updated to avoid features not supported by
non-linux os's right now (these have been generating unnecessary
warnings)

Bug: 425298118
Change-Id: I1ccc749fb3c3410b105116ff25160fc23f0336df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6648785
Commit-Queue: Struan Shrimpton <sshrimp@google.com>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
This commit is contained in:
Struan Shrimpton
2025-06-18 14:29:45 -07:00
committed by LUCI CQ
parent b51ce4941b
commit 712066553a
3 changed files with 50 additions and 46 deletions

View File

@@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from typing import Optional
import logging
import socket
import sys
@@ -46,12 +45,11 @@ def get_host_name(fully_qualified: bool = False) -> str:
try:
hostname = socket.gethostbyaddr(hostname)[0]
except (socket.gaierror, socket.herror) as e:
logging.warning(
'please check your /etc/hosts file; resolving your hostname'
' (%s) failed: %s',
hostname,
e,
)
if sys.platform.startswith('linux'):
print(
'please check your /etc/hosts file; resolving your hostname'
f' ({hostname}) failed: {e}',
file=sys.stderr)
if fully_qualified:
return hostname