<commit_before>/*=========================================================================
 *
 *  Copyright UMC Utrecht and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#include "itkOpenCLLogger.h"

#include "itkLogger.h"
#include <sstream>

namespace itk
{
// static variable initialization
OpenCLLogger::Pointer OpenCLLogger::m_Instance = 0;

//------------------------------------------------------------------------------
// Return the single instance of the OpenCLLogger
OpenCLLogger::Pointer
OpenCLLogger::GetInstance()
{
  if( !OpenCLLogger::m_Instance )
  {
    // Try the factory first
    OpenCLLogger::m_Instance = ObjectFactory< Self >::Create();
    // if the factory did not provide one, then create it here
    if( !OpenCLLogger::m_Instance )
    {
      // For the windows OS, use a special output window
      OpenCLLogger::m_Instance = new OpenCLLogger;
      // Remove extra reference from construction.
      OpenCLLogger::m_Instance->UnRegister();
    }
  }
  // Return the instance
  return OpenCLLogger::m_Instance;
}


//------------------------------------------------------------------------------
// This just calls GetInstance
OpenCLLogger::Pointer
OpenCLLogger::New()
{
  return GetInstance();
}


//------------------------------------------------------------------------------
OpenCLLogger::OpenCLLogger()
{
  this->m_FileName   = "_opencl.log";
  this->m_FileStream = NULL;
  this->m_Created    = false;
}


//------------------------------------------------------------------------------
OpenCLLogger::~OpenCLLogger()
{
  // Would prefer to close the m_FileStream, but StdStreamLogOutput
  // still performs extra flush in the destructor and setting it with null
  // not possible due to SetStream() implementation.

  //if( this->m_FileStream != NULL )
  //{
  //  delete this->m_FileStream;
  //  this->m_FileStream = NULL;
  //}
}


//------------------------------------------------------------------------------
void
OpenCLLogger::Initialize()
{
  // Construct log filename<commit_msg>PERF: fix Cppcheck report: Variable 'm_FileName' is assigned in constructor body. Consider performing initialization in initialization list.<commit_after>/*=========================================================================
 *
 *  Copyright UMC Utrecht and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#include "itkOpenCLLogger.h"

#include "itkLogger.h"
#include <sstream>

namespace itk
{
// static variable initialization
OpenCLLogger::Pointer OpenCLLogger::m_Instance = 0;

//------------------------------------------------------------------------------
// Return the single instance of the OpenCLLogger
OpenCLLogger::Pointer
OpenCLLogger::GetInstance()
{
  if( !OpenCLLogger::m_Instance )
  {
    // Try the factory first
    OpenCLLogger::m_Instance = ObjectFactory< Self >::Create();
    // if the factory did not provide one, then create it here
    if( !OpenCLLogger::m_Instance )
    {
      // For the windows OS, use a special output window
      OpenCLLogger::m_Instance = new OpenCLLogger;
      // Remove extra reference from construction.
      OpenCLLogger::m_Instance->UnRegister();
    }
  }
  // Return the instance
  return OpenCLLogger::m_Instance;
}


//------------------------------------------------------------------------------
// This just calls GetInstance
OpenCLLogger::Pointer
OpenCLLogger::New()
{
  return GetInstance();
}


//------------------------------------------------------------------------------
OpenCLLogger::OpenCLLogger() : 
m_FileName( "_opencl.log" )
{
  this->m_FileStream = NULL;
  this->m_Created    = false;
}


//------------------------------------------------------------------------------
OpenCLLogger::~OpenCLLogger()
{
  // Would prefer to close the m_FileStream, but StdStreamLogOutput
  // still performs extra flush in the destructor and setting it with null
  // not possible due to SetStream() implementation.

  //if( this->m_FileStream != NULL )
  //{
  //  delete this->m_FileStream;
  //  this->m_FileStream = NULL;
  //}
}


//------------------------------------------------------------------------------
void
OpenCLLogger::Initialize()
{
  // Construct log filename
{'fraction_non_alphanumeric': 0.2811460258780037, 'fraction_numerical': 0.0018484288354898336, 'mean_word_length': 2.102637614678899, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3103697', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1369, 'n_words': 429}