Skip to content

File ManagedLogger.h

File List > SpinnakerNET > ManagedLogger.h

Go to the documentation of this file

//=============================================================================
// Copyright (c) 2026 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of FLIR
// Integrated Imaging Solutions, Inc. ("Confidential Information"). You
// shall not disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with FLIR Integrated Imaging Solutions, Inc. (FLIR)
//
// FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================

#include "ManagedDefs.h"
#include "ManagedException.h"
#include "ManagedLoggingEventHandler.h"

using namespace ::System;
using namespace ::System::Runtime::InteropServices;

#pragma once

namespace SpinnakerNET
{

    public enum class ManagedLogType
    {
        GENTL = 0,  // Save to GenTL.log
        SPINNAKER,  // Save to Spinnaker.log
        SPINNAKERNET, // Save to SpinnakerNET.log
        NONE        // Console output only
    };

    ref class ManagedLogger
    {
        public:
            static property ManagedLogger^ Instance { ManagedLogger^ get() { return %m_instance; } }

            void log(SpinnakerNET::ManagedLoggingLevel level, ManagedLogType logType, System::String^ msg);

            void log(SpinnakerNET::ManagedLoggingLevel level, ManagedLogType logType, unsigned int msg);

            void log(SpinnakerNET::ManagedLoggingLevel level, ManagedLogType logType, System::String^ msg, System::Exception^ exceptionObject);

            void RegisterLoggingEventHandler(SpinnakerNET::ManagedLoggingEventHandler^ loggingEventHandler);

            void UnregisterLoggingEventHandler(SpinnakerNET::ManagedLoggingEventHandler^ loggingEventHandler);

            void UnregisterLoggingEventHandler();

            void SetLoggingCallbackPriority(SpinnakerNET::ManagedLoggingLevel level);

            SpinnakerNET::ManagedLoggingLevel GetLoggingCallbackPriority();

        private:
            ManagedLogger();
            ManagedLogger(const ManagedLogger%) { throw gcnew System::InvalidOperationException("singleton cannot be copy-constructed"); }
            static ManagedLogger m_instance;

            List<SpinnakerNET::ManagedLoggingEventHandler^>^ m_callbackList;
            SpinnakerNET::ManagedLoggingLevel m_level;

            void DoCallback(ManagedLoggingEventData^ loggingEvent);
    };

}