Exemplo n.º 1
0
        private void ToFile(DateTime timestamp, string target, string[] message)
        {
            // Replace unusual characters in target name with underscores
            StringBuilder cleantarget = new StringBuilder();
            foreach (char c in target) {
                if (BadFileChars.Contains(c)) cleantarget.Append('_');
                else cleantarget.Append(c);
            }
            target = cleantarget.ToString();

            string filename = _logBaseDir + target.ToLower() + "." + timestamp.ToString("yyyy-MM") + ".log";
            string prefix = "[" + timestamp.Display() + "] ";
            bool isNew = !File.Exists(filename);
            // No exception handling on purpose - failing to write a log file should be a major failure
            using (var file = new StreamWriter(new FileStream(filename, FileMode.Append), Encoding.UTF8)) {
                if (isNew) file.WriteLine(prefix + "*** Begin log file for " + target);
                foreach (string line in message) {
                    file.WriteLine(prefix + line);
                }
            }
        }
Exemplo n.º 2
0
 protected override void StartExtra()
 {
     BrewData.ResetBrewLog();
     BrewData.BrewWarmupStart = DateTime.Now;
     _startPIDMash = BrewData.MashStartTime.AddMinutes((-1) * BrewData.Config.EstimatedMashWarmupMinutes);
     _startPIDSparge = BrewData.MashStartTime.AddMinutes((-1) * BrewData.Config.EstimatedSpargeWarmupMinutes);
     BrewData.LogBrewEventToFile("Entering warmup state. Mash warmup will begin: " + _startPIDMash.Display() + ". Sparge warmup will begin: " + _startPIDSparge.Display());
 }
Exemplo n.º 3
0
 private void ToConsole(DateTime timestamp, string[] message)
 {
     string prefix = "[" + timestamp.Display() + "] ";
     foreach (string line in message) Console.WriteLine(prefix + line);
 }