public FontColor GetDefaultColors(string category) { bool success; FontColor color; switch (_currentTheme) { case VisualStudioTheme.Dark: color = new FontColor(Color.FromRgb(220, 220, 220), Color.FromRgb(30, 30, 30)); success = DarkColors.TryGetValue(category, out color); if (!success) { LoggingModule.logWarningMessage(() => String.Format("Theme manager can't read colors correctly from {0} theme.", _currentTheme)); } return(color); case VisualStudioTheme.Light: case VisualStudioTheme.Blue: default: color = new FontColor(Colors.Black, Colors.White); success = LightAndBlueColors.TryGetValue(category, out color); if (!success) { LoggingModule.logWarningMessage(() => String.Format("Theme manager can't read colors correctly from {0} theme.", _currentTheme)); } return(color); } }
private void Initialize() { _Token = _TokenSource.Token; _Settings.PrepareFilesAndDirectories(); _Indices = new KomodoIndices( _Settings.Database, _Settings.SourceDocuments, _Settings.ParsedDocuments); _Logging = new LoggingModule(_Settings.Logging.SyslogServerIp, _Settings.Logging.SyslogServerPort, _Settings.Logging.ConsoleLogging); _Logging.Settings.MinimumSeverity = _Settings.Logging.MinimumLevel; if (_Settings.Logging.FileLogging && !String.IsNullOrEmpty(_Settings.Logging.Filename)) { if (String.IsNullOrEmpty(_Settings.Logging.FileDirectory)) { _Settings.Logging.FileDirectory = "./"; } if (_Settings.Logging.FileDirectory.Contains("\\")) { _Settings.Logging.FileDirectory = _Settings.Logging.FileDirectory.Replace("\\", "/"); } if (!Directory.Exists(_Settings.Logging.FileDirectory)) { Directory.CreateDirectory(_Settings.Logging.FileDirectory); } _Logging.Settings.FileLogging = FileLoggingMode.FileWithDate; _Logging.Settings.LogFilename = _Settings.Logging.FileDirectory + _Settings.Logging.Filename; } }
internal DatabaseManager(Settings settings, LoggingModule logging, DatabaseClient database) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (database == null) { throw new ArgumentNullException(nameof(database)); } _Settings = settings; _Logging = logging; _Database = database; if (_Settings.Debug.Database) { _Database.Logger = Logger; _Database.LogQueries = true; _Database.LogResults = true; } InitializeTables(); }
public ContainerManager(Settings settings, LoggingModule logging, ConfigManager config, DatabaseClient database) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } if (database == null) { throw new ArgumentNullException(nameof(database)); } _Settings = settings; _Logging = logging; _Config = config; _Database = database; _ContainersLock = new object(); _ContainerClients = new List <ContainerClient>(); _ContainerRecheck = new Timer(); _ContainerRecheck.Elapsed += new ElapsedEventHandler(RecheckContainers); _ContainerRecheck.Interval = (_ContainerRecheckIntervalSeconds * 1000); _ContainerRecheck.Enabled = true; InitializeContainerClients(); }
private static IReadOnlyList <IModule> GetConfigurationModules( MultiSourceKeyValueConfiguration configuration, [NotNull] CancellationTokenSource cancellationTokenSource, ILogger logger, ImmutableArray <Assembly> scanAssemblies) { var modules = new List <IModule>(); if (cancellationTokenSource == null) { throw new ArgumentNullException(nameof(cancellationTokenSource)); } var loggingModule = new LoggingModule(logger); var module = new KeyValueConfigurationModule(configuration, logger); var urnModule = new UrnConfigurationModule(configuration, logger, scanAssemblies); modules.Add(loggingModule); modules.Add(module); modules.Add(urnModule); modules.Add(new MediatRModule(scanAssemblies)); return(modules); }
internal ContainerManager(Settings settings, LoggingModule logging, WatsonORM orm) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (orm == null) { throw new ArgumentNullException(nameof(orm)); } _Settings = settings; _Logging = logging; _ORM = orm; _ContainersLock = new object(); _ContainerClients = new List <ContainerClient>(); _ContainerRecheck = new Timer(); _ContainerRecheck.Elapsed += new ElapsedEventHandler(RecheckContainers); _ContainerRecheck.Interval = (_ContainerRecheckIntervalSeconds * 1000); _ContainerRecheck.Enabled = true; InitializeContainerClients(); }
private void PerformRegistrations(IGeneralOptions generalOptions) { if (generalOptions.FolderOrganizationEnabled) { SetupFolderMenu(); RegisterPriorityCommandTarget(); } if (generalOptions.GenerateReferencesEnabled) { SetupReferenceMenu(); } if (generalOptions.TaskListCommentsEnabled) { try { var componentModel = GetService(typeof(SComponentModel)) as IComponentModel; taskListCommentManager = componentModel.DefaultExportProvider.GetExportedValue <CrossSolutionTaskListCommentManager>(); Debug.Assert(taskListCommentManager != null, "This instance should have been MEF exported."); taskListCommentManager.Activate(); } catch (Exception ex) { LoggingModule.logException(ex); } } }
public FunctionMatcher(LoggingModule logging, List <FunctionApplication> apps) { if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (apps == null) { throw new ArgumentNullException(nameof(apps)); } _Logging = logging; _Apps = apps; _Definitions = new List <Definition>(); foreach (FunctionApplication app in _Apps) { foreach (Definition def in app.Functions) { _Definitions.Add(def); } } _Apps = _Apps.Distinct().ToList(); }
internal GetHandler( Settings settings, LoggingModule logging, ConfigManager config, BucketManager buckets, AuthManager auth) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } if (buckets == null) { throw new ArgumentNullException(nameof(buckets)); } if (auth == null) { throw new ArgumentNullException(nameof(auth)); } _Settings = settings; _Logging = logging; _Config = config; _Buckets = buckets; _Auth = auth; }
internal ConsoleManager( Settings settings, LoggingModule logging, ContainerManager containerMgr, ObjectHandler objects) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } if (containerMgr == null) { throw new ArgumentNullException(nameof(containerMgr)); } if (objects == null) { throw new ArgumentNullException(nameof(objects)); } _Enabled = true; _Settings = settings; _Logging = logging; _ContainerMgr = containerMgr; _Objects = objects; }
// Return true if navigation bar config is set successfully private bool SetNavigationBarConfig(bool v) { try { if (IsUserAdministrator()) { var config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); config.AppSettings.Settings.Remove(navBarConfig); config.AppSettings.Settings.Add(navBarConfig, v.ToString().ToLower()); config.Save(ConfigurationSaveMode.Minimal); return(true); } else { LoggingModule.messageBoxError(Resource.navBarUnauthorizedMessage); return(false); } } catch (Exception ex) { LoggingModule.messageBoxError(Resource.navBarErrorMessage); LoggingModule.logException(ex); return(false); } }
/// <summary> /// Create a formatted byte array containing the block. /// </summary> /// <returns>Byte array.</returns> public byte[] ToBytes() { try { byte[] ret = CfsCommon.InitByteArray(BlockSizeBytes, 0x00); Buffer.BlockCopy(DataBlock.SignatureBytes, 0, ret, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(ParentBlock), 0, ret, 4, 8); Buffer.BlockCopy(BitConverter.GetBytes(ChildBlock), 0, ret, 12, 8); Buffer.BlockCopy(BitConverter.GetBytes(DataLength), 0, ret, 20, 4); if (Data != null) { LogDebug("ToBytes copying data of length " + Data.Length + " to position 64"); Buffer.BlockCopy(Data, 0, ret, 64, Data.Length); } return(ret); } catch (Exception e) { if (Logging != null) { Logging.LogException("DataBlock", "ToBytes", e); } else { LoggingModule.ConsoleException("DataBlock", "ToBytes", e); } throw; } }
static void Main(string[] args) { log = new LoggingModule("127.0.0.1", 514); log.ConsoleEnable = true; log.IncludeUtcTimestamp = true; log.FileLogging = FileLoggingMode.FileWithDate; log.LogFilename = "syslog"; log.Debug("This is a Debug message."); log.Info("This is an Info message."); log.Warn("This is a Warn message."); log.Error("This is an Error message."); log.Alert("This is an Alert message."); log.Critical("This is a Critical message."); log.Emergency("This is an Emergency message."); log.Info("Let's test logging an exception."); int numerator = 15; int denominator = 0; try { log.Critical("Shall we divide by zero?"); int testVal = numerator / denominator; log.Warn("If you see this, there's a problem."); } catch (Exception e) { log.Exception("Program", "Main", e); } log.Alert("Press ENTER to exit"); Console.ReadLine(); }
static void Main(string[] args) { #region Process-Arguments if (args != null && args.Length > 0) { foreach (string curr in args) { if (curr.Equals("setup")) { new Setup(); } } } #endregion #region Load-Configuration if (!Common.FileExists("System.Json")) { new Setup(); } _Settings = Settings.FromFile("System.Json"); #endregion #region Initialize-Globals _Logging = new LoggingModule( _Settings.Logging.ServerIp, _Settings.Logging.ServerPort, _Settings.Logging.ConsoleLogging, (LoggingModule.Severity)_Settings.Logging.MinimumLevel, false, true, true, false, true, false); _Databases = new DatabaseManager(_Settings, _Logging); _Auth = new AuthManager(_Settings, _Logging); Console.Write("RestDb :: "); _Server = new Server( _Settings.Server.ListenerHostname, _Settings.Server.ListenerPort, _Settings.Server.Ssl, Router); _Server.Debug = _Settings.Server.Debug; #endregion Terminator.WaitOne(); }
public void RegisterTrackableLoggingModule() { _autofac.Builder.RegisterModule(new ManualTestLoggingModule(type => { _context.TypeUsedForLoggerRequest = type; return(LoggingModule.DefaultLogFactory(type)); })); }
public static CloudEngineBuilder ConfigureLogger(this CloudEngineBuilder builder, ILogProvider provider) { var module = new LoggingModule {Provider = provider}; builder.Builder.RegisterModule(module); return builder; }
internal BucketManager(Settings settings, LoggingModule logging, ConfigManager config, WatsonORM orm) { _Settings = settings ?? throw new ArgumentNullException(nameof(settings)); _Logging = logging ?? throw new ArgumentNullException(nameof(logging)); _Config = config ?? throw new ArgumentNullException(nameof(config)); _ORM = orm ?? throw new ArgumentNullException(nameof(orm)); InitializeBuckets(); }
/// <summary> /// Construct a SecurityModule object. /// </summary> /// <param name="logging">Logging module instance.</param> public SecurityModule(LoggingModule logging) { if (logging == null) { throw new ArgumentNullException(nameof(logging)); } _Logging = logging; }
internal BucketClient(Settings settings, LoggingModule logging, Bucket bucket, WatsonORM orm) { _Settings = settings ?? throw new ArgumentNullException(nameof(settings)); _Logging = logging ?? throw new ArgumentNullException(nameof(logging)); _Bucket = bucket ?? throw new ArgumentNullException(nameof(bucket)); _ORM = orm ?? throw new ArgumentNullException(nameof(orm)); InitializeStorageDriver(); }
/// <summary> /// Create a new metadata block. /// </summary> /// <param name="fs">The FileStream instance to use.</param> /// <param name="blockSize">The block size, in bytes.</param> /// <param name="parentBlock">The position of the parent block.</param> /// <param name="childDataBlock">The position of the child data block.</param> /// <param name="fullDataLength">The full length of the data represented by this metadata block.</param> /// <param name="isDirectory">Indicates if this metadata block describes a directory.</param> /// <param name="isFile">Indicates if this metadata block describes a file.</param> /// <param name="name">The name of the file or directory.</param> /// <param name="data">Byte data stored in this block.</param> /// <param name="logging">Instance of LoggingModule to use for logging events.</param> public MetadataBlock( FileStream fs, int blockSize, long parentBlock, long childDataBlock, long fullDataLength, int isDirectory, int isFile, string name, byte[] data, LoggingModule logging) { if (fs == null) { throw new ArgumentNullException(nameof(fs)); } if (blockSize < 4096) { throw new ArgumentOutOfRangeException("Block size must be greater than or equal to 4096"); } if (blockSize % 4096 != 0) { throw new ArgumentOutOfRangeException("Block size must be evenly divisible by 4096"); } if (!CfsCommon.IsTrue(isFile) && !CfsCommon.IsTrue(isDirectory)) { throw new ArgumentException("Either isFile or isDirectory must be set"); } if (CfsCommon.IsTrue(isFile) && CfsCommon.IsTrue(isDirectory)) { throw new ArgumentException("Only one of isFile and isDirectory must be set"); } Logging = logging; BlockSizeBytes = blockSize; ParentBlock = parentBlock; ChildDataBlock = childDataBlock; if (data == null) { LocalDataLength = 0; } else { LocalDataLength = data.Length; } Data = data; FullDataLength = fullDataLength; IsDirectory = isDirectory; IsFile = isFile; Name = name; DateTime ts = DateTime.Now.ToUniversalTime(); CreatedUtc = ts.ToString(DateTimeFormat); LastUpdateUtc = ts.ToString(DateTimeFormat); }
static Logger() { Logging = new LoggingModule("127.0.0.1", 514) { ConsoleEnable = true, FileLogging = FileLoggingMode.FileWithDate, LogFilename = "D:\\Users\\Mateusz\\Sources\\SparkFuzzySQL\\SparkFuzzySQL.Worker\\bin\\Debug\\netcoreapp3.1\\log.txt" }; // or Disabled, or SingleLogFile }
private bool isValidIdentifier(string ident) { bool valid = IdentifierUtils.isFixableIdentifier(ident); if (!valid) { LoggingModule.messageBoxError(Resource.invalidIdentifierMessage); } return(valid); }
public static IntegrationTestDaemon Create(Block genesisBlock = null) { var baseDirectory = TempDirectory.CreateTempDirectory(); var loggingModule = new LoggingModule(baseDirectory, LogLevel.Info); var storageModules = new[] { new EsentStorageModule(baseDirectory, ChainType.Regtest, cacheSizeMaxBytes: 500.MILLION()) }; return(new IntegrationTestDaemon(genesisBlock, baseDirectory, loggingModule, storageModules)); }
/// <summary> /// Instantiate the object. /// </summary> /// <param name="logging">LoggingModule instance.</param> public ConnectionManager(LoggingModule logging) { if (logging == null) { throw new ArgumentNullException(nameof(logging)); } _Logging = logging; _Connections = new List <Connection>(); _Lock = new object(); }
public DiskDriver(LoggingModule logging) { if (logging == null) { throw new ArgumentNullException(nameof(logging)); } _StreamReadBufferSize = 65536; _StreamWriteBufferSize = 65536; _Logging = logging; }
/// <summary> /// Create a formatted byte array containing the block. /// </summary> /// <returns>Byte array.</returns> public byte[] ToBytes() { try { byte[] ret = CfsCommon.InitByteArray(BlockSizeBytes, 0x00); Buffer.BlockCopy(MetadataBlock.SignatureBytes, 0, ret, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(ParentBlock), 0, ret, 4, 8); Buffer.BlockCopy(BitConverter.GetBytes(ChildDataBlock), 0, ret, 12, 8); Buffer.BlockCopy(BitConverter.GetBytes(FullDataLength), 0, ret, 20, 4); Buffer.BlockCopy(BitConverter.GetBytes(LocalDataLength), 0, ret, 28, 4); Buffer.BlockCopy(BitConverter.GetBytes(IsDirectory), 0, ret, 32, 4); Buffer.BlockCopy(BitConverter.GetBytes(IsFile), 0, ret, 36, 4); if (Name.Length > 256) { Name = Name.Substring(0, 256); } byte[] nameByteArray = Encoding.UTF8.GetBytes(Name); byte[] nameBytesFixed = new byte[256]; Buffer.BlockCopy(nameByteArray, 0, nameBytesFixed, 0, nameByteArray.Length); Buffer.BlockCopy(nameBytesFixed, 0, ret, 40, 256); byte[] tsByteArray = Encoding.UTF8.GetBytes(CreatedUtc); byte[] tsBytesFixed = CfsCommon.InitByteArray(32, 0x00); Buffer.BlockCopy(tsByteArray, 0, tsBytesFixed, 0, tsByteArray.Length); Buffer.BlockCopy(tsBytesFixed, 0, ret, 296, 32); tsByteArray = Encoding.UTF8.GetBytes(LastUpdateUtc); tsBytesFixed = CfsCommon.InitByteArray(32, 0x00); Buffer.BlockCopy(tsByteArray, 0, tsBytesFixed, 0, tsByteArray.Length); Buffer.BlockCopy(tsBytesFixed, 0, ret, 328, 32); if (Data != null) { LogDebug("ToBytes copying data of length " + Data.Length + " to position 512"); Buffer.BlockCopy(Data, 0, ret, 512, Data.Length); } return(ret); } catch (Exception e) { if (Logging != null) { Logging.LogException("MetadataBlock", "ToBytes", e); } else { LoggingModule.ConsoleException("MetadataBlock", "ToBytes", e); } throw; } }
static void InitializeLogging() { _Logging = new LoggingModule( _Settings.Logging.SyslogServerIp, _Settings.Logging.SyslogServerPort, _Settings.Logging.ConsoleLogging, _Settings.Logging.MinimumSeverity, false, false, true, true, false, false); }
/// <summary> /// Instantiate the object. /// </summary> /// <param name="settings">Server settings.</param> /// <param name="logging">Logging instance.</param> public CryptoManager(Settings settings, LoggingModule logging) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } _Settings = settings; _Logging = logging; }
public AuthManager(Settings settings, LoggingModule logging) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (logging == null) { throw new ArgumentNullException(nameof(logging)); } _Settings = settings; _Logging = logging; _Keys = settings.ApiKeys; }
private bool GetNavigationBarConfig() { try { var config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); var configValue = config.AppSettings.Settings[navBarConfig]; bool result; return(configValue != null && bool.TryParse(configValue.Value, out result) ? result : false); } catch (Exception ex) { LoggingModule.logException(ex); return(false); } }
static void Main(string[] args) { var config = NodeConfiguration.GetDefault(); using (var core = new CrossStitchCore(config)) { var dataStorage = new InMemoryDataStorage(); var groupName = new StitchGroupName("JsStitch", "Stitch", "1"); dataStorage.Save(new PackageFile { Id = groupName.ToString(), GroupName = groupName, Adaptor = new InstanceAdaptorDetails { Type = AdaptorType.ProcessV1, Parameters = new Dictionary <string, string> { { Parameters.DirectoryPath, "." }, { Parameters.ExecutableName, "JsStitch.Stitch.js" } } }, }, true); dataStorage.Save(new StitchInstance { Name = "JsStitch.Stitch", GroupName = groupName, State = InstanceStateType.Running, LastHeartbeatReceived = 0 }, true); var data = new DataModule(core.MessageBus, dataStorage); core.AddModule(data); var stitchesConfiguration = StitchesConfiguration.GetDefault(); var stitches = new StitchesModule(core, stitchesConfiguration); core.AddModule(stitches); var log = Common.Logging.LogManager.GetLogger("CrossStitch"); var logging = new LoggingModule(core, log); core.AddModule(logging); core.Start(); Console.ReadKey(); core.Stop(); } }