当前位置: 首页>>代码示例>>C#>>正文


C# Log.WriteLine方法代码示例

本文整理汇总了C#中Log.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# Log.WriteLine方法的具体用法?C# Log.WriteLine怎么用?C# Log.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Log的用法示例。


在下文中一共展示了Log.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

    public static bool Execute(ProjectProperties properties, Log log)
    {
        Console.WriteLine("compiling");
        var processSettings = new ProcessStartInfo();
        processSettings.FileName = properties.CscPath;
        processSettings.Arguments = properties.FormatCscArguments();

        log.WriteLine("Executing {0}", processSettings.FileName);
        log.WriteLine("Csc Arguments: {0}", processSettings.Arguments);

        processSettings.CreateNoWindow = true;
        processSettings.RedirectStandardOutput = true;
        processSettings.UseShellExecute = false;

        Process cscProcess = null;
        try
        {
            cscProcess = Process.Start(processSettings);
        }
        catch (Win32Exception)
        {
            Console.WriteLine("ERROR: csc.exe needs to be on the path.");
            return false;
        }

        var output = cscProcess.StandardOutput.ReadToEnd();
        log.WriteLine(output);

        cscProcess.WaitForExit();

        if (output.Contains("error CS")) return false;
        return true;
    }
开发者ID:dalbanhi,项目名称:corefxlab,代码行数:33,代码来源:dotnet.cs

示例2: Run

	public void Run (string rotation)
	{
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
		var log = new Log ("pdf-rotate");

		try {
			foreach (var file in FileHelper.GetFiles (FileSource.Nautilus)) {
				try {
					if (Path.GetExtension (file).ToLowerInvariant () == ".pdf") {
						Command.Run ("pdftk", string.Format ("\"{0}\" rotate 1-end{1} output \"{0}.rotated\"", file, rotation));

						if (File.Exists (file + ".rotated")) {
							FileHelper.Backup (file, "~backup");
							FileHelper.Move (file + ".rotated", file, true);
						}
					}
				}
				catch (Exception ex)
				{
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex) {
			log.WriteLine ("Error: " + ex.Message);
		}
		finally {
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:30,代码来源:pdf-rotate.cs

示例3: Run

	public void Run () {

        var log = new Log ("archive-folders");
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);

        try {

            var directories = Nautilus.SelectedFiles;
			foreach (string directory in directories) {
				try {
					if (FileHelper.IsDirectory (directory)) {
                        CleanDirectory (directory);
                        ArchiveDirectory (directory);
                    }
				}
				catch (Exception ex) {
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex) {
			log.WriteLine ("Error: " + ex.Message);
		}
		finally {
			log.Close ();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:27,代码来源:archive-folders.cs

示例4: Run

	public void Run ()
	{
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
		var log = new Log ("pdf-fix");

		try {
			foreach (var file in FileHelper.GetFiles (FileSource.Nautilus)) {
				try {
					if (Path.GetExtension (file).ToLowerInvariant () == ".pdf") {
						// repairs a PDF’s corrupted XREF table and stream lengths, if possible
						Command.Run ("pdftk", string.Format ("\"{0}\" output \"{0}.fixed\"", file));
						
						if (File.Exists (file + ".fixed")) {
							FileHelper.Backup (file, "~backup", BackupType.Numbered);
							FileHelper.Move (file + ".fixed", file, true);
						}
					}
				}
				catch (Exception ex) {
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex) {
			log.WriteLine ("Error: " + ex.Message);
		}
		finally {
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:30,代码来源:pdf-fix.cs

示例5: Run

	public void Run () {

        var log = new Log ("unzip-gmail");
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
        
        try {
            var files = Nautilus.SelectedFiles;
			foreach (string file in files) {
				try {
                    var ext = Path.GetExtension (file).ToLowerInvariant ();
					if (ext == ".zip") {
                        UnzipGmail (file);
                    }
				}
				catch (Exception ex) {
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex) {
			log.WriteLine ("Error: " + ex.Message);
		}
		finally {
			log.Close ();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:26,代码来源:unzip-gmail.cs

示例6: Run

	public void Run ()
	{
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
		var log = new Log ("pdf-to-pages-pdftk");

		try
		{
			foreach (var fileName in FileHelper.GetFiles (FileSource.Nautilus))
			{
				try
				{
					Command.Run ("pdftk", string.Format ("\"{0}\" burst", fileName));
				}
				catch (Exception ex)
				{
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex)
		{
			log.WriteLine ("Error: " + ex.Message);
		}
		finally
		{
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:28,代码来源:pdf-to-pages-pdftk.cs

示例7: Run

	public void Run ()
	{
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
		var log = new Log (ScriptName);
        
		try
		{
			var files = (Nautilus.IsNothingSelected)? Directory.GetFiles (Directory.GetCurrentDirectory ()) : Nautilus.SelectedFiles;

			foreach (string file in files)
			{
				try
				{
					var ext = Path.GetExtension (file).ToLowerInvariant ();

					if (ext == ".jpg" || ext == ".jpeg")
					{
                         // backup original files
                        FileHelper.Backup (file, "~backup", BackupType.Numbered);

                        // run convert
                        Command.Run ("convert", string.Format (
                            "\"{0}\" -auto-orient -interpolate filter -filter lanczos " +
                            "-resize {2} -quality 92 -sampling-factor 1:1:1 " +
                            "-interlace Line +repage \"{1}\"", file, file, "1280x1280>")
                        );
					}
				}
				catch (Exception ex)
				{
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex)
		{
			log.WriteLine ("Error: " + ex.Message);
		}
		finally
		{
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:43,代码来源:resize-1280px-max.cs

示例8: Run

    public void Run () {

        var log = new Log ("fix-double-ext");
        Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
        
        try {
            var files = Nautilus.SelectedFiles;
            foreach (string file in files) {
                try {
                    var ext1 = Path.GetExtension (file);
                    var fileName = Path.GetFileNameWithoutExtension (file);
                    var ext2 = Path.GetExtension (fileName);

                    if (!string.IsNullOrEmpty (ext2)) {
                        if (string.Compare (ext1, ext2, StringComparison.CurrentCultureIgnoreCase) == 0) {
                            var newFile = Path.Combine (
                                Path.GetDirectoryName (file),
                                Path.GetFileNameWithoutExtension (fileName)
                            ) + ext1;
                            
                            if (!File.Exists (newFile)) {
                                File.Move (file, newFile);
                            }
                            else {
                                log.WriteLine ("File already exists: " + newFile);
                            }                   
                        }
                    }  
                }
                catch (Exception ex) {
                    log.WriteLine ("Error: " + ex.Message);
                }
            }
	    }
        catch (Exception ex) {
            log.WriteLine ("Error: " + ex.Message);
        }
        finally {
            log.Close ();
        }
    }
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:41,代码来源:fix-double-ext.cs

示例9: Run

	public void Run ()
	{
		Console.WriteLine (Nautilus.CurrentDirectory);
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
		var log = new Log (ScriptName);

		try
		{
			var files = (Nautilus.IsNothingSelected)? Directory.GetFiles (Directory.GetCurrentDirectory ()) : Nautilus.SelectedFiles;

			foreach (string file in files)
			{
				try
				{
					var ext = Path.GetExtension (file);

					if (ext == ".wmv" || ext == ".mpeg" || ext == ".ogv" || ext == ".mkv" || ext == ".avi" || ext == ".mp4" || ext == ".flv" || ext == ".mpg")
					{
						// Console.WriteLine (OutputFileName (file, ".webm", 360));

						EncodeToWebm (file, "1M", "128k", 360);
						EncodeToMp4 (file, "1M", "128k", 360);
					}
				}
				catch (Exception ex)
				{
					log.WriteLine ("Error: " + ex.Message);
				}
			}
		}
		catch (Exception ex)
		{
			log.WriteLine ("Error: " + ex.Message);
		}
		finally
		{
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:39,代码来源:ffmpeg-360p-csharp.cs

示例10: Run

	public void Run ()
    {
		Directory.SetCurrentDirectory (Nautilus.CurrentDirectory);
        var log = new Log ("scanned-85");

		try {
			foreach (var file in FileHelper.GetFiles (FileSource.Nautilus)) {
                var ext = Path.GetExtension (file).ToLowerInvariant ();
                if (ext == ".pdf" && !FileHelper.IsDirectory (file)) {
                    var outFile = ".compressed_" +   Path.GetFileName (file);
    				try {
    					Command.Run ("convert",
                            string.Format ("-density 150x150 -quality 85 -compress jpeg \"{0}\" \"{1}\"",
                                file, outFile));

        				if (new FileInfo (file).Length > new FileInfo (outFile).Length) {
        					// compression succeded, the compressed file size is less than original file size
        					FileHelper.Backup (file, "~backup", BackupType.Numbered);
        					FileHelper.Move (outFile, file, true);
        				}
        				else {
        					// compression failed, size of the compressed file is greater or equal than original
        					File.Delete (outFile);
        				}
    				}
    				catch (Exception ex) {
    					log.WriteLine ("Error: " + ex.Message);
    				}
                }
			}
		}
		catch (Exception ex) {
			log.WriteLine ("Error: " + ex.Message);
		}
		finally {
			log.Close();
		}
	}
开发者ID:roman-yagodin,项目名称:nautilus-scripts,代码行数:38,代码来源:scanned-d150-q85.cs

示例11: RestorePackagesAction

    //static void CreateNugetConfig(ProjectProperties properties)
    //{
    //    using (var file = new StreamWriter(Path.Combine(properties.ToolsDirectory, "nuget.config"), false))
    //    {
    //    }
    //}
    public static void RestorePackagesAction(ProjectProperties properties, Log log)
    {
        Console.WriteLine("restoring packages");

        var projectFile = Path.Combine(properties.ProjectDirectory, "project.json");
        if (!File.Exists(projectFile))
        {
            projectFile = Path.Combine(properties.ToolsDirectory, "project.json");
        }

        var processSettings = new ProcessStartInfo();
        processSettings.FileName = Path.Combine(properties.ToolsDirectory, "nuget.exe");
        processSettings.Arguments = "restore " + projectFile + " -PackagesDirectory " + properties.PackagesDirectory;
        processSettings.CreateNoWindow = true;
        processSettings.UseShellExecute = false;
        processSettings.RedirectStandardOutput = true;

        log.WriteLine("Executing {0}", processSettings.FileName);
        log.WriteLine("Arguments: {0}", processSettings.Arguments);
        log.WriteLine("project.json:\n{0}", File.ReadAllText(projectFile));

        var process = Process.Start(processSettings);
        var output = process.StandardOutput.ReadToEnd();
        log.WriteLine(output);

        process.WaitForExit();
    }
开发者ID:dalbanhi,项目名称:corefxlab,代码行数:33,代码来源:dotnet.cs

示例12: CheckHeaderForNumbers

 private static void CheckHeaderForNumbers(Log log, List<string> map)
 {
     //Check map for numbers to throw a warning if no header has been set
     foreach (string sCol in map)
     {
         double dTemp;
         if (double.TryParse(sCol, out dTemp))
             log.WriteLine(LogLevel.Warning, "Column \"{0}\" seems to be a number and should be a column title. Maybe you forgot to add a header line?", sCol);
         else
             log.WriteLine(LogLevel.Debug, "Column \"{0}\" seems to be text, this is good.", sCol);
     }
 }
开发者ID:harmanpa,项目名称:csv-compare,代码行数:12,代码来源:CsvFile.cs

示例13: CsvFile

        /// The constructor reads the csv file to this object
        /// @para filename The full path of the csv file
        /// @para dTolerance Double value containing the delta for the tube generation
        public CsvFile(string fileName, Options options, Log log)
        {
            //Parse tolerance from commandline
            NumberFormatInfo toleranceProvider = new NumberFormatInfo();
            toleranceProvider.NumberDecimalSeparator = ".";

            //understand 0.002
            if (!Double.TryParse(options.Tolerance, NumberStyles.AllowDecimalPoint, toleranceProvider, out _dRangeDelta))
            {
                //understand 0,002
                toleranceProvider.NumberDecimalSeparator = ",";
                if (!Double.TryParse(options.Tolerance, NumberStyles.AllowDecimalPoint, toleranceProvider, out _dRangeDelta))
                    //understand 2e-2 etc.
                    if (!Double.TryParse(options.Tolerance, out _dRangeDelta))
                        log.WriteLine(LogLevel.Warning, "could not parse given tolerance argument: \"{0}\", using default \"{1}\".", options.Tolerance, _dRangeDelta);
            }

            if (File.Exists(fileName))
            {
                _fileName = Path.GetFullPath(fileName);
                using (TextReader reader = new StreamReader(fileName))
                {
                    string sLine = reader.ReadLine();
                    if (null == sLine)
                        throw new ArgumentNullException(string.Format("\"{0}\" is empty, nothing to parse here.", fileName));

            #if DEBUG           //Do some benchmarking in DEBUG mode
                    Stopwatch timer = new Stopwatch();
                    timer.Start();
            #endif
                    List<string> map = new List<string>();

                    //skip comments
                    while ( string.IsNullOrEmpty( sLine ) || sLine.StartsWith( "#", StringComparison.OrdinalIgnoreCase ) )
                        sLine = reader.ReadLine();

                    Regex reg = new Regex(string.Format(CultureInfo.CurrentCulture, "{0}(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))", options.Delimiter));

                    //read the columns from the first line
                    string[] values = reg.Split(sLine);

                    //one element means the line has not been parsed correctly
                    if (null == values || values.Length == 1)
                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "The file {0} could not be parsed. Maybe the wrong delimiter is set? It has been set to \"{1}\".", fileName, options.Delimiter));

                    foreach (string sCol in values)
                        if (!string.IsNullOrEmpty(sCol))
                        {
                            string sTemp = sCol.Trim(' ', '"', '\t', '\'');
                            if (sTemp != "t" && sTemp != "time" && sTemp != "Time")//Skip time values
                            {
                                try
                                {
                                    _values.Add(sTemp, new List<double>());
                                    map.Add(sTemp);
                                }
                                catch (ArgumentException)
                                {
                                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Error parsing the csv file \"{0}\". The result {1} is already in the list (maybe you set no or a wrong delimiter for the parser? I used \"{2}\").",
                                        fileName, sTemp, options.Delimiter));
                                }
                            }
                        }

            #if DEBUG
                    log.WriteLine(LogLevel.Debug, "Parsed header in {0}ms", timer.ElapsedMilliseconds);
                    timer.Restart();
            #endif
                    CheckHeaderForNumbers(log, map);
            #if DEBUG
                    log.WriteLine(LogLevel.Debug, "Checked header in {0}ms", timer.ElapsedMilliseconds);
                    timer.Restart();
            #endif
                    //read the rest of the csv file
                    while ((sLine = reader.ReadLine()) != null)
                    {
                        //Skip comments
                        if (sLine.StartsWith("#", StringComparison.OrdinalIgnoreCase))
                            continue;

                        //values = reg.Split(sLine); //splitting using regular expressions is slow
                        IEnumerable<string> dataValues;
                        if ( options.Delimiter.Equals( options.Separator ) )
                            throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, "The delimiter \"{0}\" and separator \"{1}\" are equal. This makes correct parsing impossible.",
                                options.Delimiter, options.Separator ) );
                        else
                            dataValues = Tokenize( sLine, options.Delimiter ); //use custom tokenizer for improved performance

                        int iCol = 0;

                        NumberFormatInfo provider = new NumberFormatInfo();
                        provider.NumberDecimalSeparator = options.Separator.ToString();

                        //read values to the dictionary
                        foreach (string sCol in dataValues)
                        {
                            double dValue;
//.........这里部分代码省略.........
开发者ID:harmanpa,项目名称:csv-compare,代码行数:101,代码来源:CsvFile.cs

示例14: PlotCsvFile

        public Report PlotCsvFile(string sReportPath, Log log)
        {
            Report r = new Report(sReportPath);
            log.WriteLine("Generating plot for report");

            foreach (KeyValuePair<string, List<double>> res in _values)
            {
                Curve compare = new Curve(res.Key, this.XAxis.ToArray<double>(), res.Value.ToArray<double>());
                PrepareCharts(r, compare);
            }

            return r;
        }
开发者ID:harmanpa,项目名称:csv-compare,代码行数:13,代码来源:CsvFile.cs

示例15: CompareFiles

        public Report CompareFiles(Log log, CsvFile csvBase, string sReportPath, ref Options options)
        {
            int iInvalids = 0;

            Report rep = new Report(sReportPath);
            log.WriteLine("Comparing \"{0}\" to \"{1}\"", _fileName, csvBase.ToString());

            rep.BaseFile = csvBase.ToString();
            rep.CompareFile = _fileName;

            Curve reference = new Curve();
            Curve compareCurve = new Curve();
            TubeReport tubeReport = new TubeReport();
            TubeSize size = null;
            Tube tube = new Tube(size);
            IOptions tubeOptions = new Options1(_dRangeDelta, Axes.X);

            foreach (KeyValuePair<string, List<double>> res in csvBase.Results)
            {
                if (!this.Results.ContainsKey(res.Key))
                    log.WriteLine(LogLevel.Warning, "{0} not found in \"{1}\", skipping checks.", res.Key, this._fileName);
                else
                {
                    compareCurve = new Curve(res.Key, this.XAxis.ToArray<double>(), this.Results[res.Key].ToArray<double>());

                    if (res.Value.Count == 0)
                    {
                        log.Error("{0} has no y-Values! Maybe error during parsing? Skipping", res.Key);
                        continue;
                    }
                    reference = new Curve("Reference ", csvBase.XAxis.ToArray(), csvBase.Results[res.Key].ToArray());
                    if (!reference.ImportSuccessful)
                    {
                        log.Error("Error in the calculation of the tubes. Skipping {0}", res.Key);
                        rep.Chart.Add(new Chart() { Title = res.Key, Errors = 1 });
                        continue;
                    }

                    if (reference.X.Length < compareCurve.X.Length)
                        log.WriteLine(LogLevel.Warning, "The resolution of the base x-axis is smaller than the compare x-axis. The better the base resolution is, the better the validation result will be!");
                    else
                        log.WriteLine(LogLevel.Debug, "The resolution of the base x-axis is good.");

                    size = new TubeSize(reference, true);
                    size.Calculate(_dRangeDelta, Axes.X, Relativity.Relative);
                    tube = new Tube(size);
                    tubeReport = tube.Calculate(reference);
                    tube.Validate(compareCurve);

                    if (tubeReport.Valid == Validity.Valid)
                        log.WriteLine(res.Key + " is valid");
                    else
                    {
                        log.WriteLine(LogLevel.Warning, "{0} is invalid! {1} errors have been found during validation.", res.Key,
                            (null != tube.Report.Errors && null != tube.Report.Errors.X) ? tube.Report.Errors.X.Length : 0);
                        iInvalids++;
                        Environment.ExitCode = 1;
                    }
                }
                if (null != tube.Report)//No charts for missing reports
                    PrepareCharts(reference, compareCurve, tube.Report.Errors, rep, tubeReport, res, options.UseBitmapPlots);
            }
            rep.Tolerance = _dRangeDelta;

            string sResult = "na";

            if (rep.TotalErrors == 0)
                sResult = "passed";
            else
                sResult = "failed";

            if (options.ComparisonFlag)
                using (TextWriter writer = File.CreateText(string.Format("{0}{1}compare_{2}.log", Path.GetDirectoryName(_fileName), Path.DirectorySeparatorChar, sResult)))
                {
                    //Content needs to be defined
                    writer.WriteLine("CSV Compare Version {0} ({1})", Info.AssemblyVersion, Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture);
                    writer.WriteLine("Comparison result file for {0}", _fileName);
                    writer.WriteLine(". Time:        {0:o}", DateTime.Now);
                    writer.WriteLine(". Operation:   {0}", options.Mode);
                    writer.WriteLine(". Tolerance:   {0}", options.Tolerance);
                    writer.WriteLine(". Result:      {0}", sResult);

                    if (rep.TotalErrors > 0)
                    {
                        Chart pairMax = rep.Chart.Aggregate((l, r) => l.DeltaError > r.DeltaError ? l : r);
                        writer.WriteLine(". Biggest error: {0}=>{1}", pairMax.Title, pairMax.DeltaError);
                        writer.WriteLine(". Failed values:");

                        foreach (Chart c in (from r in rep.Chart where r.DeltaError > 0 select r).OrderByDescending(er => er.DeltaError))
                            writer.WriteLine("{0}=>{1}", c.Title, c.DeltaError);
                    }
                }

            rep.WriteReport(log, (!string.IsNullOrEmpty(options.ReportDir)) ? options.ReportDir : string.Empty, options);
            GC.Collect();//immediately forget big charts and data
            return rep;
        }
开发者ID:harmanpa,项目名称:csv-compare,代码行数:97,代码来源:CsvFile.cs


注:本文中的Log.WriteLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。