Example #1
0
        private static void TestCustomConsoleOut()
        {
            //First we want to Specify what Messages we want to let trough the LogStream we are creating in a minute.

            //You have multiple ways to create a Bitmask without getting cancer from bitwise operations
            var bMaskWildCard = new BitMask(true); //Creates a Wildcard(Everything will be let through)
            var bMaskNone     = new BitMask();     //Creates the opposite of Wildcard(Nothing will be let through)

            //There are also more readable ways to create a mask.
            //For example with enums. The Implementation will stay the same.
            var bMaskGenericWildcard = new BitMask <LoggingTypes>(true);
            var bMaskGenericNone     = new BitMask <LoggingTypes>();

            //But you can do masks easier now.
            //This bitmask only lets through logs and errors
            var bMaskGenericCustom = new BitMask <LoggingTypes>(LoggingTypes.Error, LoggingTypes.Log);

            //We want to Create a PipeStream that our logstream is basing on(pipe streams are threadsave streams in a single sender/single receiver situation)
            var pipeStream = new PipeStream(); //Create a new instance


            //Then we want to create a LogStream that receives the Messages
            //Important: Its much easier to use CreateLogStreamFromStream than setting everything manually
            var logStream = new LogStream(
                pipeStream,           //The Stream we want to send the Logs to.
                bMaskGenericWildcard, //Lets use the generic wildcard(you can set the mask dynamically when using a custom console.
                MatchType.MatchOne,   //We want to make the logs pass when all tags are included in the filter.
                true                  //Get that fancy timestamp infront of the log.
                );

            //logStream.OverrideChannelTag = false;
            Debug.AddOutputStream(logStream); //Now we have Created the stream, just add it to the system.


            //After Creating the log Stream we want to create a custom Cmd window
            var ccmd
                =                                           //ADL.CustomCMD.CMDUtils.CreateCustomConsole(pipeStream); //Creates a basic Custom cmd with no visual adjustments
                  CmdUtils.CreateCustomConsole(pipeStream); //Creates a custom cmd with color coding and custom font size.

            (ccmd as ADL.CustomCMD.CustomCmdForm).FontColor = Color.White;


            Debug.LogGen(LoggingTypes.Log, "Finished adding the CustomConsole.");

            //Now we want to remove the stream from the system.
            //Debug.RemoveOutputStream(logStream, true); //We want to remove a single one.
            //But we can remove all Streams in one go
            //Debug.RemoveAllOutputStreams(true);
        }