public IBTree LoadBTree(object id) { var oid = (OID)id; try { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Format("LazyOdbBtreePersister: Loading btree with id {0}", oid)); } if (oid == StorageEngineConstant.NullObjectId) { throw new OdbRuntimeException( BTreeError.InvalidIdForBtree.AddParameter(StorageEngineConstant.NullObjectId)); } _tree = (IBTree)_engine.GetObjectFromOid(oid); _tree.SetId(oid); _tree.SetPersister(this); var root = _tree.GetRoot(); root.SetBTree(_tree); return(_tree); } catch (Exception e) { throw new OdbRuntimeException(BTreeError.InternalError, e); } }
public void SetValue(Java.Lang.String value) { returnValue = value.ToString(); try { latch.CountDown(); } catch (System.Exception ex) { DLogger.WriteLog(ex); } }
public System.Reflection.ConstructorInfo GetConstructorOf(System.String fullClassName) { System.Type clazz = classPool.GetClass(fullClassName); try { // Checks if exist a default constructor - with no parameters System.Reflection.ConstructorInfo constructor = clazz.GetConstructor(new System.Type[0]); return(constructor); } catch (System.MethodAccessException e) { // else take the constructer with the smaller number of parameters // and call it will null values // @TODO Put this inf oin cache ! if (OdbConfiguration.IsDebugEnabled(LogId)) { DLogger.Debug(clazz + " does not have default constructor! using a 'with parameter' constructor will null values"); } System.Reflection.ConstructorInfo[] constructors = clazz.GetConstructors(); int numberOfParameters = 1000; int bestConstructorIndex = 0; for (int i = 0; i < constructors.Length; i++) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" if (constructors[i].GetParameters().Length < numberOfParameters) { bestConstructorIndex = i; } } System.Reflection.ConstructorInfo constructor = constructors[bestConstructorIndex]; return(constructor); } }
private void btnSearching_Click(object sender, EventArgs e) { DateTime searchingDate = new DateTime(); DateTime.TryParseExact(txtSearchingDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out searchingDate); int hour = 0; int min = 0; int.TryParse(txtHour.Text, out hour); int.TryParse(txtMins.Text, out min); lbStatus.Text = $"Searching for data in {searchingDate.ToString("dd/MM/yyyy")} at {hour.ToString("00")}:{min.ToString("00")}"; switch (cbxSearchingMode.SelectedIndex) { case 0: // searching by dd DLogger.SearchingData(searchingDate, hour, min, DLogger.SearchingMode.SDAY) .ContinueWith(data => txtSearchingData.SetPropertyThreadSafe(() => txtSearchingData.Text, data.Result)); break; case 1: // searching by HH DLogger.SearchingData(searchingDate, hour, min, DLogger.SearchingMode.SHOUR) .ContinueWith(data => txtSearchingData.SetPropertyThreadSafe(() => txtSearchingData.Text, data.Result)); break; case 2: // searching by HH:mm DLogger.SearchingData(searchingDate, hour, min, DLogger.SearchingMode.SHOUR_AND_MIN) .ContinueWith(data => txtSearchingData.SetPropertyThreadSafe(() => txtSearchingData.Text, data.Result)); break; } }
public void When_File_Was_Deleted_Try_Writing_Log() { //ARRANGE string path = @"C:\Logs\Test\TestFile.txt"; FileInfo fileInfo = new FileInfo(path); if (fileInfo.DirectoryName != null && Directory.Exists(fileInfo.DirectoryName)) { Directory.Delete(fileInfo.DirectoryName, true); } DLogger logger = new DLogger(); //ACT logger.AddTargetFile(path); logger.AddTargetFile(fileInfo); File.Delete(path); logger.Write("Test"); //ASSERT Assert.IsTrue(File.ReadAllText(path).Contains("Test")); File.Delete(path); }
public long ReadOidPosition(OID oid) { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug("ObjectReader: Start of readOidPosition for oid " + oid); } var blockNumber = StorageEngineConstant.GetIdBlockNumberOfOid(oid); var blockPosition = GetIdBlockPositionFromNumber(blockNumber); if (OdbConfiguration.IsLoggingEnabled()) { var blockNumberAsString = blockNumber.ToString(); var blockPositionAsString = blockPosition.ToString(); DLogger.Debug(string.Format("ObjectReader: Block number of oid {0} is ", oid) + blockNumberAsString + " / block position = " + blockPositionAsString); } var position = blockPosition + StorageEngineConstant.BlockIdOffsetForStartOfRepetition + ((oid.ObjectId - 1) % StorageEngineConstant.NbIdsPerBlock) * StorageEngineConstant.IdBlockRepetitionSize; if (OdbConfiguration.IsLoggingEnabled()) { var positionAsString = position.ToString(); DLogger.Debug(string.Format("ObjectReader: End of readOidPosition for oid {0} returning position ", oid) + positionAsString); } return(position); }
// Use this for initialization void Start() { // Log at the Info level (Equal). DLogger.Log("script2 - Started. Note the prefix should be what you configured."); // Log at the Debug Level (Less). DLogger.Debug("script2 - In script1 we set log level to Info, this should not display"); }
/// <summary> /// Gets the real object position from its OID /// </summary> /// <param name="oid"> The oid of the object to get the position </param> /// <param name="useCache"> </param> /// <param name="throwException"> To indicate if an exception must be thrown if object is not found </param> /// <returns> The object position, if object has been marked as deleted then return StorageEngineConstant.DELETED_OBJECT_POSITION @ </returns> public long GetObjectPositionFromItsOid(OID oid, bool useCache, bool throwException) { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug("ObjectReader: getObjectPositionFromItsId for oid " + oid); } // Check if oid is in cache var position = StorageEngineConstant.ObjectIsNotInCache; if (useCache) { // This return -1 if not in the cache position = _storageEngine.GetSession().GetCache().GetObjectPositionByOid(oid); } // FIXME Check if we need this. Removing it causes the TestDelete.test6 to fail if (position == StorageEngineConstant.DeletedObjectPosition) { if (throwException) { throw new CorruptedDatabaseException(NDatabaseError.ObjectIsMarkedAsDeletedForOid.AddParameter(oid)); } return(StorageEngineConstant.DeletedObjectPosition); } if (position != StorageEngineConstant.ObjectIsNotInCache && position != StorageEngineConstant.DeletedObjectPosition) { return(position); } // The position was not found is the cache position = ReadOidPosition(oid); position += StorageEngineConstant.BlockIdRepetitionIdStatus; _fsi.SetReadPosition(position); var idStatus = _fsi.ReadByte(); var objectPosition = _fsi.ReadLong(); if (!IDStatus.IsActive(idStatus)) { // if object position == 0, The object dos not exist if (throwException) { if (objectPosition == 0) { throw new CorruptedDatabaseException(NDatabaseError.ObjectWithOidDoesNotExist.AddParameter(oid)); } throw new CorruptedDatabaseException(NDatabaseError.ObjectIsMarkedAsDeletedForOid.AddParameter(oid)); } return(objectPosition == 0 ? StorageEngineConstant.ObjectDoesNotExist : StorageEngineConstant.DeletedObjectPosition); } if (OdbConfiguration.IsLoggingEnabled()) { var positionAsString = objectPosition.ToString(); DLogger.Debug("ObjectReader: object position of object with oid " + oid + " is " + positionAsString); } return(objectPosition); }
void Awake() { // Configure the Logger with your desired prefix and log level. DLogger.Configure("My Game", DLogger.LogLevels.Info); // Log at the Debug Log Level (Less). DLogger.Debug("script1 - This debug message will not recorded."); // Log at the Info Log Level (Equal). DLogger.Info("script1 - I configured my logger in script1"); }
/// <summary> /// Registers the logger. /// </summary> /// <remarks> /// Automatically enables the logging. /// </remarks> /// <param name="logger">The logger.</param> public static void RegisterLogger(ILogger logger) { if (!IsLoggingEnabled()) { EnableLogging(); } DLogger.Register(logger); }
/// <summary> /// Read the class info header with the specific oid /// </summary> /// <returns> The read class info object @ </returns> public ClassInfo ReadClassInfoHeader(OID classInfoOid) { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug("FileSystemReader: Reading new Class info Header with oid " + classInfoOid); } var classInfoPosition = GetObjectPositionFromItsOid(classInfoOid, true, true); _fsi.SetReadPosition(classInfoPosition); var blockSize = _fsi.ReadInt(); var blockType = _fsi.ReadByte(); if (!BlockTypes.IsClassHeader(blockType)) { throw new OdbRuntimeException( NDatabaseError.WrongTypeForBlockType.AddParameter("Class Header").AddParameter(blockType). AddParameter(classInfoPosition)); } //class info category, to remove _fsi.ReadByte(); var classInfoId = OIDFactory.BuildClassOID(_fsi.ReadLong()); var previousClassOID = ReadOid(); var nextClassOID = ReadOid(); var nbObjects = _fsi.ReadLong(); var originalZoneInfoFirst = ReadOid(); var originalZoneInfoLast = ReadOid(); var fullClassName = _fsi.ReadString(); var maxAttributeId = _fsi.ReadInt(); var attributesDefinitionPosition = _fsi.ReadLong(); var classInfo = new ClassInfo(fullClassName) { Position = classInfoPosition, ClassInfoId = classInfoId, PreviousClassOID = previousClassOID, NextClassOID = nextClassOID, MaxAttributeId = maxAttributeId, AttributesDefinitionPosition = attributesDefinitionPosition }; classInfo.OriginalZoneInfo.SetNbObjects(nbObjects); classInfo.OriginalZoneInfo.First = originalZoneInfoFirst; classInfo.OriginalZoneInfo.Last = originalZoneInfoLast; classInfo.CommitedZoneInfo.SetBasedOn(classInfo.OriginalZoneInfo); // FIXME Convert block size to long ?? var realBlockSize = (int)(_fsi.GetPosition() - classInfoPosition); if (blockSize != realBlockSize) { throw new OdbRuntimeException( NDatabaseError.WrongBlockSize.AddParameter(blockSize).AddParameter(realBlockSize).AddParameter( classInfoPosition)); } return(classInfo); }
private void Persist() { _nbPersist++; if (OdbConfiguration.IsLoggingEnabled()) { var count = _modifiedObjectOids.Count.ToString(); DLogger.Debug(string.Concat("LazyOdbBtreePersister: ", "persist ", _nbPersist.ToString(), " : Saving " + count + " objects - ", GetHashCode().ToString())); } var nbCommited = 0; var i = 0; var size = _modifiedObjectOids.Count; IEnumerator iterator = _modifiedObjectOidList.GetEnumerator(); while (iterator.MoveNext()) { var oid = (OID)iterator.Current; if (oid == null) { continue; } nbCommited++; long t0; long t1; try { t0 = OdbTime.GetCurrentTimeInMs(); var @object = _oids[oid]; _engine.Store(@object); t1 = OdbTime.GetCurrentTimeInMs(); } catch (Exception e) { throw new OdbRuntimeException( BTreeError.InternalError.AddParameter("Error while storing object with oid " + oid), e); } if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Concat("LazyOdbBtreePersister: ", "Committing oid " + oid, " | ", i.ToString(), "/", size.ToString(), " | ", (t1 - t0).ToString(), " ms")); } i++; } if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Debug(string.Concat("LazyOdbBtreePersister: ", nbCommited.ToString(), " commits / ", size.ToString())); } }
/// <summary> /// Adds a write action to the transaction /// </summary> /// <param name="writeAction"> The write action to be added </param> /// <param name="persistWriteAction"> To indicate if write action must be persisted </param> private void AddWriteAction(WriteAction writeAction, bool persistWriteAction) { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Info(string.Format("OdbTransaction: Adding WriteAction in Transaction of session {0}", _session.GetId())); } if (writeAction.IsEmpty()) { return; } CheckRollback(); if (!_hasBeenPersisted && persistWriteAction) { Persist(); } if (persistWriteAction) { writeAction.PersistMeTo(_fsi); } // Only adds the write action to the list if the transaction keeps all in // memory if (_hasAllWriteActionsInMemory) { _writeActions.Add(writeAction); } _numberOfWriteActions++; if (_hasAllWriteActionsInMemory && _numberOfWriteActions > StorageEngineConstant.MaxNumberOfWriteObjectPerTransaction) { _hasAllWriteActionsInMemory = false; foreach (var defaultWriteAction in _writeActions) { defaultWriteAction.Clear(); } _writeActions.Clear(); if (OdbConfiguration.IsLoggingEnabled()) { var numberOfWriteActions = _numberOfWriteActions.ToString(); var maxNumberOfWriteObjectPerTransactionAsString = StorageEngineConstant.MaxNumberOfWriteObjectPerTransaction.ToString(); DLogger.Info("OdbTransaction: Number of objects has exceeded the max number " + numberOfWriteActions + "/" + maxNumberOfWriteObjectPerTransactionAsString + ": switching to persistent transaction managment"); } } }
public void Test() { #if DEBUG #if WIN //ensures CEF is referenced as expected CefErrorCode err = CefErrorCode.Aborted; DLogger.WriteLog(err.ToString()); #endif #endif }
// This is the main entry point of the application. static void Main(string[] args) { //do it asap DLogger.Initialize(AppHelper.Paths.WorkingRootFolder); CoreTest.Initialize(); // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. UIApplication.Main(args, null, "AppDelegate"); }
public void Log(Exception e) { if (IsLogin) { DLogger.GetLogger <IUserSnap>(Me.Account).Info(e); } else { DLogger.GetLogger <IUserSnap>(AnonymousUserDLogCode).Info(e); } }
public void Log(string message) { if (IsLogin) { DLogger.GetLogger <IUserSnap>(Me.Account).Info(message); } else { DLogger.GetLogger <IUserSnap>(AnonymousUserDLogCode).Info(message); } }
public void Log(string format, object[] args) { if (IsLogin) { DLogger.GetLogger <IUserSnap>(Me.Account).InfoFormat(format, args); } else { DLogger.GetLogger <IUserSnap>(AnonymousUserDLogCode).InfoFormat(format, args); } }
public virtual void OpenUrlInSystemBrowser(string url) { try { System.Diagnostics.Process.Start(url); } catch (Exception ex) { DLogger.WriteLog(ex); #if WIN System.Diagnostics.Process.Start("IEXPLORE.EXE", url); #endif } }
public void Init(int _seed = 0) { if (!init) { DLogger.Log("DRandom::Initializing RNG - Seed = " + _seed); init = true; seed = _seed; random = new Random(seed); } }
void Start() { // No level will log. DLogger.All("I will not show up in the console because logging is off."); DLogger.Trace("I will not show up in the console because logging is off."); DLogger.Debug("I will not show up in the console because logging is off."); DLogger.Info("I will not show up in the console because logging is off."); DLogger.Warn("I will not show up in the console because logging is off."); DLogger.Error("I will not show up in the console because logging is off."); DLogger.Fatal("I will not show up in the console because logging is off."); }
/// <summary> /// 注册wrap的函数 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="callerWrap"></param> public void RegWrapInterface <T>(T callerWrap, object listInst) { string typeName = typeof(T).FullName; DLogger.Assert(!m_entry.ContainsKey(typeName)); var entry = new DEventEntryData(); entry.m_interfaceWrap = callerWrap; entry.m_listIntefaceImp = listInst; m_entry.Add(typeName, entry); }
void Awake() { // Configure the logger as normal. DLogger.Configure("My Game", DLogger.LogLevels.Info); DLogger.Log("Logs."); // Some check to see if we should not be logging. if (this.isProduction) { DLogger.TurnOff(); } DLogger.Log("Does not log."); }
static void Main(string[] args) { //Start Logger DLogger mainProgramLogger = new DLogger(DLogger.LogLevel.Info, "Stock_Analytics"); //Start Up Message String startMessage = String.Format("{0}{1}", "Welcom to Stock Analytics - Ver.", Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine(startMessage); mainProgramLogger.QueueLogMessage(startMessage, DLogger.LogLevel.Info, typeof(Program)); mainProgramLogger.Dispose(); }
public virtual NeoDatis.Odb.Objects <T> GetObjects <T>(NeoDatis.Odb.Core.Query.IQuery query, bool inMemory, int startIndex, int endIndex) { try { return(storageEngine.GetObjects <T>(query, inMemory, startIndex, endIndex)); } catch (ODBRuntimeException e) { DLogger.Info(e); throw e; } }
// Use this for initialization void Awake() { // Configure the Logger with your desired prefix and log level. DLogger.Configure("My Game", DLogger.LogLevels.Debug); // Log at the Debug Log Level (Equal). DLogger.Debug("This debug message will be recorded."); // Log at the Trace Log Level (Lower). DLogger.Trace("This trace message will not be recorded."); // Log at the Info Log Level (Higher). DLogger.Info("This info message will be recored."); // Log at the Info Log Level (Higher). DLogger.Log("This general log (info) message will be recorded."); }
private void CloseIO() { try { _odbWriter.Dispose(); } catch (IOException e) { DLogger.Error("NonBufferedFileIO" + e); throw new OdbRuntimeException(NDatabaseError.InternalError.AddParameter(e.Message), e); } _odbWriter = null; }
/// <summary> /// Used to rebuild an index /// </summary> public void RebuildIndex(string className, string indexName) { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Info(string.Format("StorageEngine: Rebuilding index {0} on class {1}", indexName, className)); } var classInfo = GetMetaModel().GetClassInfo(className, true); var classInfoIndex = GetClassInfoIndex(className, indexName, classInfo); DeleteIndex(className, indexName); AddIndexOn(className, indexName, classInfo.GetAttributeNames(classInfoIndex.AttributeIds), !classInfoIndex.IsUnique); }
/// <summary> /// Receive the current class info (loaded from current classes present on runtime and check against the persisted meta model /// </summary> public bool Check(IDictionary <Type, ClassInfo> currentCIs, IMetaModelService metaModelService) { foreach (var persistedCI in metaModelService.GetAllClasses()) { CheckClass(currentCIs, persistedCI); } foreach (var result in _results) { DLogger.Info(string.Format("MetaModelCompabilityChecker: Class {0} has changed :", result.GetFullClassName())); DLogger.Info("MetaModelCompabilityChecker: " + result); } return(_results.Count != 0); }
private void UpdateMetaModel() { if (OdbConfiguration.IsLoggingEnabled()) { DLogger.Info("StorageEngine: Automatic refactoring : updating meta model"); } var metaModel = GetMetaModel(); var storedClasses = metaModel.GetAllClasses().ToList(); foreach (var userClass in storedClasses) { _objectWriter.UpdateClassInfo(userClass, true); } }