예제 #1
0
        public static ControllerLogger Create(string sourceName, EventingStorage storage)
        {
            ControllerLogger Logger = new ControllerLogger(sourceName,
                                                           storage,
                                                           CAPTURE_STACK_TRACE | ENABLE_ALL_MASK);

            if (Logger != null)
            {
                Logger.Register();
            }

            return(Logger);
        }
예제 #2
0
        //  Public methods

        //  Private methods

        internal override void Initialize()
        {
            base.Initialize();

            EventTable         = new Hashtable();
            SourcesLookupTable = new Hashtable();
            SourcesHandleTable = new Hashtable();

            UIntPtr RepositoryStorageHandle = FetchLocalStorage();

            if (RepositoryStorageHandle != 0)
            {
                TypesRepository = EventingStorage.CreateStorageFromHandle(RepositoryStorageHandle);

                //  Fetch now the existing source list created before initializing the controller

                int        currentSize = 20;
                UIntPtr [] sourceArray = new UIntPtr[currentSize];

                if (sourceArray != null)
                {
                    unsafe
                    {
                        fixed(UIntPtr *ptr = sourceArray)
                        {
                            int sourceCount = QuerySystemSources(ptr, (ushort)currentSize);

                            while (sourceCount > currentSize)
                            {
                                sourceArray = new UIntPtr[sourceCount];
                                sourceCount = QuerySystemSources(ptr, (ushort)currentSize);
                            }

                            for (int i = 0; i < sourceCount; i++)
                            {
                                UIntPtr sourceHandle  = sourceArray[i];
                                UIntPtr storageHandle = 0;
                                string  bufferName    = "";

                                if (GetNativeSourceName(sourceHandle, ref storageHandle, ref bufferName))
                                {
                                    EventSource source = new EventSource(this, bufferName, storageHandle);

                                    if (source != null)
                                    {
                                        source.Register();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                TypesRepository = EventingStorage.CreateLocalStorage(QualityOfService.PermanentEvents,
                                                                     BUFFER_EXPANSION_SIZE);
                SetRepositoryStorage(TypesRepository.GetHandle());
            }

            string sourceName = "ControllerLog";

#if SINGULARITY_KERNEL
            sourceName = sourceName + "{kernel}";
#else
            unsafe {
                int    argMaxLen = ProcessService.GetStartupArg(0, null, 0);
                char[] argArray  = new char [argMaxLen];


                fixed(char *argptr = &argArray[0])
                {
                    int len = ProcessService.GetStartupArg(0,
                                                           argptr,
                                                           argArray.Length);

                    sourceName = sourceName + "{" + String.StringCTOR(argptr, 0, len) + "}";
                    sourceName = sourceName + "(PID:" + ProcessService.GetCurrentProcessId() + ")";
                }
            }
#endif

            InternalSource = ControllerLogger.Create(sourceName, TypesRepository);
        }