Menu

ScriptLogger Log in to Edit

Jan Siems

The Class Scriptlogger is a static class wich allows multilevel logging within the .NET and Stealth Envirement.

Before calling the ScriptLogger for firsttime, you always should keep sure to call ScriptLogger.Initialize();.

Properties

  • LogToStealth (Administration of Logfiles wich should be written to Stealth Console)
  • LogToIDE (Administration of Logfiles wich should be written to Visual Studio´s Debug Console)
  • LogToConsole (Administration of Logfiles wich should be written to native Console)
  • LogToFile (Administration of logfiles wich should be written to file designed on property "FileName")
  • FileName (Administration of wich file the LogToFile method should write)

Functions

  • Initialize() => Configurate basic handling
  • WriteLine(string text) => Writes text to enabled logging engine. 1 Text means 1 line.
  • Write(string text) => Analog to WriteLine, but on Console not calls a new Line.

Events

  • OnLogging : ScriptLoggerArgs => Allows to Handle Custom Logging. ScriptLoggerArgs containing Text and if method writeline (full = true) or method write (full = false) has been called.

Sample

using System;
using ScriptSDK.Engines;

namespace App
{
    internal static class Program
    {
        [STAThread]
        private static void Main()
        {
            ScriptLogger.Initialize(); // Should be always called once before using the ScriptLogger
            ScriptLogger.LogToStealth = true; //Allows logger to Write to Stealth UI Console
            ScriptLogger.LogToConsole = true; //Allows logger to Write to .Net Console (if active)
            ScriptLogger.LogToIDE = true; //Allows logger to write to Visual Studio related Debug Log
            /*
             Sends Text to Enabled Engines. On IDE and Console its a print without linebreak, on Stealth with Linebreak
             */
            ScriptLogger.Write("Hello World");
            /*
             Sends Text to Enabled Engines. On IDE and Console its a print with linebreak
             */
            ScriptLogger.Write("Hello World with a new line :D");
        }
    }
}

Related

Wiki: Snippets

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.