<commit_before>﻿// Copyright (c) 2017-2021 Ubisoft Entertainment
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Sharpmake.Generators;
using Sharpmake.Generators.VisualStudio;

namespace Sharpmake.Application
{
    public enum ExitCode
    {
        Success = 0,
        Error = -3,
        InternalError = -3,
        UnknownError = -10
    }

    public static partial class Program
    {
        [DefaultValue(None)]
        internal enum TestOptions
        {
            None,
            Regression,
            QuickConfigure,
            Configure
        }

        #region Log

        private static DateTime s_startTime = DateTime.Now;
        public static bool DebugEnable = false;
        private static int s_errorCount = 0;
        private static int s_warningCount = 0;

        public static void LogWrite(string format, params object[] args)
        {
            LogWrite(string.Format(format, args));
        }

        public static void LogWrite(string message)
        {
            string prefix = string.Empty;

            if (DebugEnable)
            {
                TimeSpan span = DateTime.Now - s_startTime;
                prefix = string.Format("[{0:00}:{1:00}] ", span.Minutes, span.Seconds);
                message = prefix + message;
            }

            Console.Write(message);
            if (Debugger.IsAttached)
            {
                message = message.Replace(prefix + Util.CallerInfoTag, string.Empty);
                Trace.Write(message);
            }
        }

        public static void LogWriteLine(string format, params object[] args)
        {
            LogWriteLine(string.Format(format, args));
        }

        public static void LogWriteLine(string msg)
        {
            LogWrite(msg + Environment.NewLine);
        }

        public static void DebugWrite(string format, params object[] args)
        {
            DebugWrite(string.Format(format, args));
        }

        public static void DebugWrite(string message)
        {
            if (DebugEnable)
            {
                TimeSpan span = DateTime.Now - s_startTime;

                string prefix = string.Format("[{0:00}:{1:00}] ", span.Minutes, span.Seconds);
                message = prefix + message;

                Console.Write(message);
                if (Debugger.IsAttached)
                    Trace.Write(message);
            }
        }

        public static void DebugWriteLine(string format, params object[] args)
        {
            DebugWriteLine(string.Format(format, args));
        }

        public static void DebugWriteLine(string msg)
        {
            if (DebugEnable)
                DebugWrite(msg + Environment.NewLine);
        }

        public static void WarningWrite(string format, params object[] args)
        {
            WarningWrite(string.Format(format, args));
        }

        public static void WarningWrite(string msg)
        {
            Interlocked.Increment(ref s_warningCount);
            Console.Write(msg);
            if (Debugger.IsAttached)
                Trace.Write(msg);
        }

        public static void WarningWriteLine(string format, params object[] args)
        {
            WarningWriteLine(string.Format(format, args));
        }

        public static void WarningWriteLine(string msg)
        {
            WarningWrite(msg + Environment.NewLine);
        }

        public static void ErrorWrite(string format, params object[] args)
        {
            ErrorWrite(string.Format(format, args));
        }

        public static void ErrorWrite(string msg)
        {
            Interlocked.Increment(ref s_errorCount);
            Console.Write(msg);
            if (Debugger.IsAttached)
                Trace.Write(msg);
        }

        public static void ErrorWriteLine(string format, params object[] args)
        {
            ErrorWriteLine(string.Format(format, args));
        }

        public static void ErrorWriteLine(string msg)
        {
            ErrorWrite(msg + Environment.NewLine);
        }

        #endregion

        private static int Main()
        {
            if (CommandLine.ContainParameter("breakintodebugger"))
            {
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    System.Windows.Forms.MessageBox.Show("Debugger requested. Please attach a debugger and press OK");
                }
                else
                {
                    Console.WriteLine("Debugger requested. Please attach a debugger and press ENTER to continue");<commit_msg>Clarify logs level (Error, Warning, ...)<commit_after>﻿// Copyright (c) 2017-2021 Ubisoft Entertainment
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Sharpmake.Generators;
using Sharpmake.Generators.VisualStudio;

namespace Sharpmake.Application
{
    public enum ExitCode
    {
        Success = 0,
        Error = -3,
        InternalError = -3,
        UnknownError = -10
    }

    public static partial class Program
    {
        [DefaultValue(None)]
        internal enum TestOptions
        {
            None,
            Regression,
            QuickConfigure,
            Configure
        }

        #region Log

        private static DateTime s_startTime = DateTime.Now;
        public static bool DebugEnable = false;
        private static int s_errorCount = 0;
        private static int s_warningCount = 0;

        public static void LogWrite(string format, params object[] args)
        {
            LogWrite(string.Format(format, args));
        }

        public static void LogWrite(string message)
        {
            string prefix = string.Empty;

            if (DebugEnable)
            {
                TimeSpan span = DateTime.Now - s_startTime;
                prefix = string.Format("[{0:00}:{1:00}] ", span.Minutes, span.Seconds);
                message = prefix + message;
            }

            Console.Write(message);
            if (Debugger.IsAttached)
            {
                message = message.Replace(prefix + Util.CallerInfoTag, string.Empty);
                Trace.Write(message);
            }
        }

        public static void LogWriteLine(string format, params object[] args)
        {
            LogWriteLine(string.Format(format, args));
        }

        public static void LogWriteLine(string msg)
        {
            LogWrite(msg + Environment.NewLine);
        }

        public static void DebugWrite(string format, params object[] args)
        {
            DebugWrite(string.Format(format, args));
        }

        public static void DebugWrite(string msg)
        {
            if (DebugEnable)
            {
                LogWrite(msg);
            }
        }

        public static void DebugWriteLine(string format, params object[] args)
        {
            DebugWriteLine(string.Format(format, args));
        }

        public static void DebugWriteLine(string msg)
        {
            if (DebugEnable)
                DebugWrite(msg + Environment.NewLine);
        }

        public static void WarningWrite(string format, params object[] args)
        {
            WarningWrite(string.Format(format, args));
        }

        public static void WarningWrite(string msg)
        {
            Interlocked.Increment(ref s_warningCount);
            LogWrite("[WARNING]" + msg);
        }

        public static void WarningWriteLine(string format, params object[] args)
        {
            WarningWriteLine(string.Format(format, args));
        }

        public static void WarningWriteLine(string msg)
        {
            WarningWrite(msg + Environment.NewLine);
        }

        public static void ErrorWrite(string format, params object[] args)
        {
            ErrorWrite(string.Format(format, args));
        }

        public static void ErrorWrite(string msg)
        {
            Interlocked.Increment(ref s_errorCount);
            LogWrite("[ERROR]" + msg);
        }

        public static void ErrorWriteLine(string format, params object[] args)
        {
            ErrorWriteLine(string.Format(format, args));
        }

        public static void ErrorWriteLine(string msg)
        {
            ErrorWrite(msg + Environment.NewLine);
        }

        #endregion

        private static int Main()
        {
            if (CommandLine.ContainParameter("breakintodebugger"))
            {
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    System.Windows.Forms.MessageBox.Show("Debugger requested. Please attach a debugger and press OK");
                }
                else
                {
                    Console.WriteLine("Debugger requested. Please attach a debugger and press ENTER to continue");
{'fraction_non_alphanumeric': 0.08392960742602978, 'fraction_numerical': 0.0058015857667762525, 'mean_word_length': 1.8461750137589432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1663323', 'n_tokens_mistral': 2593, 'n_tokens_neox': 2476, 'n_words': 727}