Esempio n. 1
0
        /// <summary>
        /// Create a logger that writes to a file.
        /// There will be multiple files (rotated the number of minutes specified)
        ///     and each filename will begin with "MetaverseServer-".
        /// The target directory is created if it doesn't exist.
        /// </summary>
        /// <param name="pLogDirectory">Directory to create the log files</param>
        /// <param name="pAlsoLogToConsole">if 'true', also write to the console each message</param>
        public LogFileLogger(string pLogDirectory, bool pAlsoLogToConsole = false) : base()
        {
            string logDir = EntityStorage.GenerateAbsStorageLocation(pLogDirectory);

            // Verify the log directory exists
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            if (pAlsoLogToConsole)
            {
                _consoleLogger          = new ConsoleLogger();
                _consoleLogger.LogLevel = LogLevel;
            }

            // Initialize the logger with a default log level.
            int  rotateMinutes = Context.Params.P <int>(AppParams.P_LOGGER_ROTATE_MINS);
            bool forceFlush    = Context.Params.P <bool>(AppParams.P_LOGGER_FORCE_FLUSH);

            _logWriter = new LogWriter(logDir, "MetaverseServer-", rotateMinutes, forceFlush);
        }
Esempio n. 2
0
        public RESTReplyData get_metaverse_info(RESTRequestData pReq, List<string> pArgs)
        {
            RESTReplyData replyData = new RESTReplyData();  // The HTTP response info

            JObject jo = new JObject
            {

                // Start with the basic parameters
                ["metaverse_name"] = Context.Params.P<string>(AppParams.P_METAVERSE_NAME),
                ["metaverse_nick_name"] = Context.Params.P<string>(AppParams.P_METAVERSE_NICKNAME),
                ["metaverse_url"] = Context.Params.P<string>(AppParams.P_METAVERSE_SERVER_URL),
                ["ice_server_url"] = Context.Params.P<string>(AppParams.P_DEFAULT_ICE_SERVER),
                ["metaverse_server_version"] = ThisAssembly.AssemblyInformationalVersion
            };

            // See if there are additions in the info file
            string infoFile = EntityStorage.GenerateAbsStorageLocation(null, Context.Params.P<string>(AppParams.P_METAVERSE_INFO_FILE));
            if (File.Exists(infoFile))
            {
                try
                {
                    string fContents = File.ReadAllText(infoFile);
                    JObject jContents = JObject.Parse(fContents);
                    foreach (JProperty jprop in jContents.Properties())
                    {
                        jo[jprop.Name] = jprop.Value;
                    }
                }
                catch (Exception e)
                {
                    Context.Log.Error("{0} Exception reading metaverse info file {1}: {2}",
                                        _logHeader, infoFile, e);
                }
            }   

            replyData.SetBody( JsonConvert.SerializeObject(jo, Formatting.Indented) );

            return replyData;
        }
Esempio n. 3
0
 // Load the site parameters.
 // The initialization of AppParams is a two step process because this step depends on the default and command line parameters
 public void LoadSiteParameters()
 {
     _siteParameters = new ParamPersistant(EntityStorage.GenerateAbsStorageLocation(null, this.P <string>(AppParams.P_CONFIGFILE)));
     _siteParameters.SetParameterDefaultValues();
 }