Exemple #1
0
        public string ReportOptions(Report report)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("===============================================================================");
            sb.AppendLine("[Global scope options]");

            sb.AppendLine(ArgsOnlyHandler.Report());
            sb.AppendLine(DebugHandler.Report());
            sb.AppendLine(InitFileHandler.Report());
            sb.AppendLine(ScriptHandler.Report());
            sb.AppendLine(TraceHandler.Report());
            sb.AppendLine(VerboseHandler.Report());
            sb.AppendLine(VerifyHandler.Report());
            sb.AppendLine(VerifyMemoryHandler.Report());

            sb.AppendLine("[Session scope options]");
            sb.AppendLine(report.Session.ReportOptions());

            sb.AppendLine("[Report scope options]");
            sb.AppendLine(report.ReportOptions());
            sb.AppendLine("===============================================================================");

            return(sb.ToString());
        }
        public static async Task Test0Async()
        {
            Storage storage = new FileStorage("http://*****:*****@"c:\data\site\resolver");

            FileSystemEmulatorHandler handler = new VerboseHandler
            {
                BaseAddress = new Uri("http://*****:*****@"c:\data\site",
                InnerHandler = new HttpClientHandler()
            };

            ResolverCollector collector = new ResolverCollector(storage, 200);

            //await collector.Run(new Uri("http://localhost:8000/full/index.json"), DateTime.MinValue);
            //await collector.Run(new Uri("http://partitions.blob.core.windows.net/partition0/index.json"), DateTime.MinValue);
            await collector.Run(new Uri("http://localhost:8000/partition/partition0/index.json"), DateTime.MinValue, handler);
            Console.WriteLine("http requests: {0} batch count: {1}", collector.RequestCount, collector.BatchCount);
        }
Exemple #3
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("usage logging.exe mw-id=<middleware ID>");
            return(-1);
        }

        //o Load the command-line input into a GMSEC Config object
        // A Config object is basically a key-value pair map which is used to
        // pass configuration options into objects such as Connections,
        // ConnectionManagers, Subscribe and Publish function calls, Messages,
        // etc.
        Config config = new Config(args);

        ErrorHandler   errorHandler   = new ErrorHandler();
        WarningHandler warningHandler = new WarningHandler();
        InfoHandler    infoHandler    = new InfoHandler();
        VerboseHandler verboseHandler = new VerboseHandler();
        DebugHandler   debugHandler   = new DebugHandler();
        AnyHandler     anyHandler     = new AnyHandler();

        Log.RegisterHandler(LoggingLevel.ERROR, errorHandler);
        Log.RegisterHandler(LoggingLevel.WARNING, warningHandler);
        Log.RegisterHandler(LoggingLevel.INFO, infoHandler);
        Log.RegisterHandler(LoggingLevel.VERBOSE, verboseHandler);
        Log.RegisterHandler(LoggingLevel.DEBUG, debugHandler);

        //o Set logging reporting level
        Log.SetReportingLevel(LoggingLevel.VERBOSE);
        Log.Verbose("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Print the GMSEC API version number using the GMSEC Logging
        // interface
        // This is useful for determining which version of the API is
        // configured within the environment
        // TODO: Once available, replace this statement with usage of
        // ConnectionManager::getAPIVersion (See RTC 4798)
        Log.Info(Connection.GetAPIVersion());

        try
        {
            //o Create the ConnectionManager
            ConnectionManager connMgr = new ConnectionManager(config);

            //o Connect
            Log.Info("Opening the connection to the middleware server");
            connMgr.Initialize();

            //o Output middleware client/wrapper version
            Log.Info(connMgr.GetLibraryVersion());

            //o Publish a message
            PublishTestMessage(connMgr, "GMSEC.TEST.PUBLISH");

            //o Disconnect from the middleware and clean up the Connection
            connMgr.Cleanup();
        }
        catch (Exception e)
        {
            Log.Error(e.ToString());
            return(-1);
        }

        //o Unregister log handlers
        Log.RegisterHandler(null);

        //o Set log stream to stderr
        config.AddValue("LOGFILE", "STDERR");

        Log.Info("This message should go to stderr, not stdout.  " +
                 "For example, in bash test by running as:\n" +
                 "./logging mw-id=bolt 2> testfile.txt\n" +
                 "... and then check the contents of testfile.txt");

        //o Reset log stream to stdout
        config.AddValue("LOGFILE", "STDOUT");

        Log.Error("This is an example error message.");
        Log.Warning("This is an example warning message.");
        Log.Verbose("This is an example \"verbose\" message.");
        Log.Debug("This is an example debug message which should not show.");

        // This last message cannot be shown right now because
        // Log::setReportingLevel(logVERBOSE), used above, does not
        // allow DEBUG messages to come out.
        Log.Verbose("This is another example \"verbose\" message.");

        Log.SetReportingLevel(LoggingLevel.DEBUG);
        if (Log.GetReportingLevel() == LoggingLevel.DEBUG)
        {
            Log.Info("Changed reporting level to logDEBUG");
        }
        else
        {
            Log.Error("Failed to change reporting level to logDEBUG");
        }

        // The DEBUG message below will be shown successfully, unlike the last
        // debug message.
        Log.Debug("This is an example debug message which should show.");

        Log.Debug("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Debug("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Debug("SECURE reporting level, numerically, is " + Log.LevelFromString("SECURE"));
        Log.Debug("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Debug("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Debug("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Register general-purpose handler and test
        Log.RegisterHandler(anyHandler);

        Log.Error("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Error("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Warning("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Info("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Verbose("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Unregister log handlers
        Log.RegisterHandler(null);

        return(0);
    }
Exemple #4
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("Error: Missing arg.\n");
            Console.WriteLine("Usage: ./logging mw-id=<middleware>");
            return(-1);
        }

        Config config = new Config(args);

        //o Create and register custom log handlers
        ErrorHandler   eh = new ErrorHandler();
        WarningHandler wh = new WarningHandler();
        InfoHandler    ih = new InfoHandler();
        VerboseHandler vh = new VerboseHandler();
        DebugHandler   dh = new DebugHandler();
        GeneralHandler gh = new GeneralHandler();

        //  Note: Registration of VERBOSE and DEBUG custom log handlers will
        //        be ignored at the Core API level.
        //
        Log.Info("**** Registering all custom log handlers ****");
        Log.RegisterHandler(LogLevel.logERROR, eh);
        Log.RegisterHandler(LogLevel.logWARNING, wh);
        Log.RegisterHandler(LogLevel.logINFO, ih);
        Log.RegisterHandler(LogLevel.logVERBOSE, vh);
        Log.RegisterHandler(LogLevel.logDEBUG, dh);

        //o Set log reporting level
        Log.SetReportingLevel(LogLevel.logINFO);
        Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Display the GMSEC API version
        Log.Info("API version: " + ConnectionManager.GetAPIVersion());

        try
        {
            //o Create a ConnectionManager
            using (ConnectionManager connMgr = new ConnectionManager(config))
            {
                //o Connect to the GMSEC Bus
                connMgr.Initialize();

                //o Disconnect from the GMSEC Bus
                connMgr.Cleanup();
            }
        }
        catch (GmsecException e)
        {
            Log.Error("Exception: " + e.ToString());
            return(-1);
        }

        //o Unregister all custom log handlers
        Log.Info("**** Un-registering all custom log handlers ****");
        Log.RegisterHandler(null);

        //o Examples of logging messages
        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");
        Log.Debug("This is a DEBUG message");              // This message will not be displayed

        //o Reset log reporting level so that all log message are displayed
        Log.SetReportingLevel(LogLevel.logDEBUG);

        //o Confirm logging level
        if (Log.GetReportingLevel() == LogLevel.logDEBUG)
        {
            Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());
        }
        else
        {
            Log.Error("The log reporting level was NOT changed to logDEBUG");
        }
        Log.Debug("A DEBUG message can now be displayed");

        //o Convert log level names to LogLevel enumerated values
        Log.Error("ERROR reporting level as enum value: " + Log.FromString("ERROR"));
        Log.Warning("WARNING reporting level as enum value: " + Log.FromString("WARNING"));
        Log.Info("INFO reporting level as enum value: " + Log.FromString("INFO"));
        Log.Verbose("VERBOSE reporting level as enum value: " + Log.FromString("VERBOSE"));
        Log.Debug("DEBUG reporting level as enum value: " + Log.FromString("DEBUG"));

        //o Reset log reporting level so that only INFO and below are displayed
        Log.SetReportingLevel(LogLevel.logINFO);

        //o Replace all custom log handlers with a general purpose custom log handler
        Log.Info("**** Registering all general purpose custom log handler ****");
        Log.RegisterHandler(gh);

        Log.Error("ERROR reporting level as string: " + Log.ToString(LogLevel.logERROR));
        Log.Warning("WARNING reporting level as string: " + Log.ToString(LogLevel.logWARNING));
        Log.Info("INFO reporting level as string: " + Log.ToString(LogLevel.logINFO));
        Log.Verbose("VERBOSE reporting level as string: " + Log.ToString(LogLevel.logVERBOSE));           // Not displayed
        Log.Debug("DEBUG reporting level as string: " + Log.ToString(LogLevel.logDEBUG));                 // Not displayed

        //o Unregister (all) custom log handler(s)
        Log.Info("**** Un-registering custom log handler ****");
        Log.RegisterHandler(null);

        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");          // Not displayed
        Log.Debug("This is a DEBUG message");              // Not displayed

        return(0);
    }