Skip to content

Studio/src/Data/StudioLog.h

Namespaces

Name
shapeworks

Classes

Name
class shapeworks::StudioLog

Defines

Name
STUDIO_LOG_STACK(message)
Log stack macro.
STUDIO_LOG_MESSAGE(message)
Log message macro.
STUDIO_LOG_ERROR(message)
Log error macro.
STUDIO_CLOSE_LOG()
Close session macro.
STUDIO_FLUSH_LOG()
Close session macro.

Macros Documentation

define STUDIO_LOG_STACK

#define STUDIO_LOG_STACK(
    message
)
shapeworks::StudioLog::Instance().log_stack( message )

Log stack macro.

define STUDIO_LOG_MESSAGE

#define STUDIO_LOG_MESSAGE(
    message
)
shapeworks::StudioLog::Instance().log_message( message, __LINE__, __FILE__ )

Log message macro.

define STUDIO_LOG_ERROR

#define STUDIO_LOG_ERROR(
    message
)
shapeworks::StudioLog::Instance().log_error( message, __LINE__, __FILE__ )

Log error macro.

define STUDIO_CLOSE_LOG

#define STUDIO_CLOSE_LOG(

)
shapeworks::StudioLog::Instance().close_log();

Close session macro.

define STUDIO_FLUSH_LOG

#define STUDIO_FLUSH_LOG(

)
shapeworks::StudioLog::Instance().flush_log();

Close session macro.

Source code

#pragma once

#include <string>
#include <fstream>
#include <QString>

namespace shapeworks {

class StudioLog {

public:

  StudioLog();

  static StudioLog& Instance();

  void new_log();

  void log_message(QString message, const int line, const char* file);

  void log_stack(std::string message);

  void log_error(QString message, const int line, const char* file);

  void log_debug(QString message, const int line, const char* file);

  void close_log();

  void flush_log();

  bool check_log_open();

  QString get_log_filename();

private:

  QString create_header(const int line, const char* filename );

  QString get_current_datetime();

  std::ofstream log_; 

  QString log_filename_;

  static const QString datetime_format_;

  static const QString log_datetime_format_;
};



#define STUDIO_LOG_STACK(message) \
  shapeworks::StudioLog::Instance().log_stack( message )

#define STUDIO_LOG_MESSAGE(message) \
  shapeworks::StudioLog::Instance().log_message( message, __LINE__, __FILE__ )

#define STUDIO_LOG_ERROR(message) \
  shapeworks::StudioLog::Instance().log_error( message, __LINE__, __FILE__ )

#define STUDIO_CLOSE_LOG() \
  shapeworks::StudioLog::Instance().close_log();

#define STUDIO_FLUSH_LOG() \
  shapeworks::StudioLog::Instance().flush_log();
}

Updated on 2022-03-31 at 09:51:19 -0600