"vscode:/vscode.git/clone" did not exist on "f9c38c090c3d75bcf3ad6ae71a83d5aea5125995"
log.py 690 Bytes
Newer Older
liugh5's avatar
liugh5 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logging
import subprocess


def logging_to_file(log_file):
    logger = logging.getLogger()
    handler = logging.FileHandler(log_file)
    formatter = logging.Formatter(
        "%(asctime)s %(levelname)-4s [%(filename)s:%(lineno)d] %(message)s",
        datefmt="%Y-%m-%d:%H:%M:%S",
    )
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)


def get_git_revision_short_hash():
    return (
        subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
        .decode("ascii")
        .strip()
    )


def get_git_revision_hash():
    return subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()