public static void Init(BluffinMuffinDataSection config)
        {
            if (!config.Logging.DbCommand.HasIt)
                return;

            Database.InitDatabase(config.Logging.DbCommand.Url, config.Logging.DbCommand.User, config.Logging.DbCommand.Password, config.Logging.DbCommand.Database);
            
            DataTypes.Logger.CommandSent += OnLogCommandSent;
            DataTypes.Logger.CommandReceived += OnLogCommandReceived;
            DataTypes.Logger.TableCreated += OnLogTableCreated;
            DataTypes.Logger.GameCreated += OnLogGameCreated;
            DataTypes.Logger.GameEnded += OnLogGameEnded;
            DataTypes.Logger.ClientCreated += OnLogClientCreated;

            m_LogServer = new Logger.DBAccess.Server($"{Assembly.GetEntryAssembly().GetName().Name} {Assembly.GetEntryAssembly().GetName().Version.ToString(3)}", Assembly.GetAssembly(typeof(AbstractCommand)).GetName().Version);
            m_LogServer.RegisterServer();

        }
예제 #2
0
        public static void Init(BluffinMuffinDataSection config)
        {
            DataTypes.Logger.ErrorLogged += (sender, args) => LogError(args.Str);
            DataTypes.Logger.WarningLogged += (sender, args) => LogWarning(args.Str);

            switch (config.Logging.Console.Level)
            {
                case ConsoleLoggerConfigElement.LVL_VERBOSE:
                    DataTypes.Logger.VerboseInformationLogged += (sender, args) => LogVerboseInformation(args.Str);
                    goto case ConsoleLoggerConfigElement.LVL_DEBUG;
                case ConsoleLoggerConfigElement.LVL_DEBUG:
                    DataTypes.Logger.DebugInformationLogged += (sender, args) => LogDebugInformation(args.Str);
                    goto case ConsoleLoggerConfigElement.LVL_NORMAL;
                case ConsoleLoggerConfigElement.LVL_NORMAL:
                    DataTypes.Logger.InformationLogged += (sender, args) => LogInformation(args.Str);
                    break;
            }
        }
예제 #3
0
 public static void Init(BluffinMuffinDataSection config)
 {
     var uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
     var path = $"{Path.GetDirectoryName(uri.LocalPath + uri.Fragment)}\\log";
     if (!Directory.Exists(path))
         Directory.CreateDirectory(path);
     var logName = DateTime.Now.ToString("yyyy-MM-dd.HH-mm-ss");
     switch (config.Logging.File.Level)
     {
         case FileLoggerConfigElement.LVL_VERBOSE:
         {
             var sw = File.CreateText($"{path}\\server.{logName}.verbose.txt");
             sw.AutoFlush = true;
             DataTypes.Logger.ErrorLogged += (sender, args) => LogError(sw, args.Str);
             DataTypes.Logger.WarningLogged += (sender, args) => LogWarning(sw, args.Str);
             DataTypes.Logger.InformationLogged += (sender, args) => LogInformation(sw, args.Str);
             DataTypes.Logger.DebugInformationLogged += (sender, args) => LogDebugInformation(sw, args.Str);
             DataTypes.Logger.VerboseInformationLogged += (sender, args) => LogDebugInformation(sw, args.Str);
             goto case FileLoggerConfigElement.LVL_DEBUG;
         }
         case FileLoggerConfigElement.LVL_DEBUG:
         {
             var sw = File.CreateText($"{path}\\server.{logName}.debug.txt");
             sw.AutoFlush = true;
             DataTypes.Logger.ErrorLogged += (sender, args) => LogError(sw, args.Str);
             DataTypes.Logger.WarningLogged += (sender, args) => LogWarning(sw, args.Str);
             DataTypes.Logger.InformationLogged += (sender, args) => LogInformation(sw, args.Str);
             DataTypes.Logger.DebugInformationLogged += (sender, args) => LogDebugInformation(sw, args.Str);
             goto case FileLoggerConfigElement.LVL_NORMAL;
         }
         case FileLoggerConfigElement.LVL_NORMAL:
         {
             var sw = File.CreateText($"{path}\\server.{logName}.txt");
             sw.AutoFlush = true;
             DataTypes.Logger.ErrorLogged += (sender, args) => LogError(sw, args.Str);
             DataTypes.Logger.WarningLogged += (sender, args) => LogWarning(sw, args.Str);
             DataTypes.Logger.InformationLogged += (sender, args) => LogInformation(sw, args.Str);
             break;
         }
     }
 }