<commit_before><commit_msg>Script to show steamCache log in colour with Depot Name.<commit_after>#!/bin/bash

############################
#
# This script will show the log from the Steam Cache in colours
# (Red: Remote, Green: Local, Orange: other).
# Where it can, it will try and find the name of the depot being
# downloaded and show that as part of the output.
#
############################

TMPDIR=/tmp/cache/
CACHELOG=/srv/steamcache/access.log

getGameName() {

  if ! [ -s ${TMPDIR}${1} ]; then
    wget -O /tmp/cache/$1 https://steamdb.info/depot/$1/ >/dev/null 2>&1
  fi

    #Allows for when something goes wrong with the name.
  G=`cat ${TMPDIR}${1} | grep "\<h1" | sed 's/.*header-title\">//;s/<\/h1.*//'`

  echo $G
}

tail -f ${CACHELOG} | while read LINE; do

  GAMEID=`echo ${LINE} | sed 's/.*\/depot\/\([0-9]*\)\/.*/\1/'`
  GAMENAME=`getGameName ${GAMEID}`

  echo "(${GAMENAME}) ${LINE}" | awk '
    /LOCAL/ {print "\033[32m" $0 "\033[39m"}
    /REMOTE/ {print "\033[31m" $0 "\033[39m"}
    /OTHER/ {print "\033[33m" $0 "\033[39m"}
  '
done

{'fraction_non_alphanumeric': 0.24293785310734464, 'fraction_numerical': 0.04143126177024482, 'mean_word_length': 3.286290322580645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4062344', 'n_tokens_mistral': 436, 'n_tokens_neox': 401, 'n_words': 115}