DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ers::LocalContext Class Reference

#include <LocalContext.hpp>

Inheritance diagram for ers::LocalContext:
[legend]
Collaboration diagram for ers::LocalContext:
[legend]

Public Member Functions

 LocalContext (const char *package_name, const char *filename, int line_number, const char *function_name, bool debug=false)
virtual ~LocalContext ()
virtual Context * clone () const
const char * cwd () const
const char * file_name () const
const char * function_name () const
const char * host_name () const
int line_number () const
const char * package_name () const
pid_t process_id () const
pid_t thread_id () const
void *const * stack_symbols () const
int stack_size () const
int user_id () const
const char * user_name () const
const char * application_name () const
Public Member Functions inherited from ers::Context
virtual ~Context ()
std::string position (int verbosity=ers::Configuration::instance().verbosity_level()) const
std::vector< std::string > stack () const

Static Public Member Functions

static void resetProcessContext ()

Private Attributes

const char *const m_package_name
const char *const m_file_name
const char *const m_function_name
const int m_line_number
const pid_t m_thread_id
void * m_stack [64]
const int m_stack_size

Static Private Attributes

static const LocalProcessContext c_process

Detailed Description

Definition at line 58 of file LocalContext.hpp.

Constructor & Destructor Documentation

◆ LocalContext()

ers::LocalContext::LocalContext ( const char * package_name,
const char * filename,
int line_number,
const char * function_name,
bool debug = false )

creates a new instance of a local context for an issue. This constructor should not be called directly, instead one should use the ERS_HERE macro.

Parameters
package_namename of the current sw package
filenamename of the source code file
line_numberline_number in the source code
function_namename of the current function

Definition at line 88 of file LocalContext.cpp.

94 , m_file_name(filename)
98 , m_stack_size(debug ? backtrace(m_stack, std::size(m_stack)) : 0)
99{
100 ;
101}
pid_t gettid()
const char * function_name() const
int line_number() const
const char *const m_file_name
const char *const m_function_name
const char * package_name() const
const pid_t m_thread_id
const char *const m_package_name
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:91

◆ ~LocalContext()

virtual ers::LocalContext::~LocalContext ( )
inlinevirtual

Definition at line 74 of file LocalContext.hpp.

74{ ; }

Member Function Documentation

◆ application_name()

const char * ers::LocalContext::application_name ( ) const
virtual
Returns
application name

Implements ers::Context.

Definition at line 104 of file LocalContext.cpp.

105{
106 static int pid = ::getpid();
107 static const char* env = ::getenv("DUNEDAQ_APPLICATION_NAME") ? ::getenv("DUNEDAQ_APPLICATION_NAME") : "Undefined";
108
109 if (pid != ::getpid()) {
110 pid = ::getpid();
111 env = ::getenv("DUNEDAQ_APPLICATION_NAME") ? ::getenv("DUNEDAQ_APPLICATION_NAME") : "Undefined";
112 }
113 return env;
114}

◆ clone()

virtual Context * ers::LocalContext::clone ( ) const
inlinevirtual

<

Returns
copy of the current context

Implements ers::Context.

Definition at line 76 of file LocalContext.hpp.

76{ return new LocalContext(*this); }
LocalContext(const char *package_name, const char *filename, int line_number, const char *function_name, bool debug=false)

◆ cwd()

const char * ers::LocalContext::cwd ( ) const
inlinevirtual

<

Returns
current working directory of the process

Implements ers::Context.

Definition at line 78 of file LocalContext.hpp.

78{ return c_process.m_cwd; }
static const LocalProcessContext c_process
const char *const m_cwd

◆ file_name()

const char * ers::LocalContext::file_name ( ) const
inlinevirtual

<

Returns
name of the file which created the issue

Implements ers::Context.

Definition at line 80 of file LocalContext.hpp.

80{ return m_file_name; }

◆ function_name()

const char * ers::LocalContext::function_name ( ) const
inlinevirtual

<

Returns
name of the function which created the issue

Implements ers::Context.

Definition at line 82 of file LocalContext.hpp.

83 {
84 return m_function_name;
85 }

◆ host_name()

const char * ers::LocalContext::host_name ( ) const
inlinevirtual

<

Returns
host where the process is running

Implements ers::Context.

Definition at line 87 of file LocalContext.hpp.

87{ return c_process.m_host_name; }
const char *const m_host_name

◆ line_number()

int ers::LocalContext::line_number ( ) const
inlinevirtual

<

Returns
line number, in which the issue has been created

Implements ers::Context.

Definition at line 89 of file LocalContext.hpp.

89{ return m_line_number; }

◆ package_name()

const char * ers::LocalContext::package_name ( ) const
inlinevirtual

<

Returns
CMT package name

Implements ers::Context.

Definition at line 91 of file LocalContext.hpp.

91{ return m_package_name; }

◆ process_id()

pid_t ers::LocalContext::process_id ( ) const
inlinevirtual

<

Returns
process id

Implements ers::Context.

Definition at line 93 of file LocalContext.hpp.

93{ return ::getpid(); }

◆ resetProcessContext()

void ers::LocalContext::resetProcessContext ( )
static

◆ stack_size()

int ers::LocalContext::stack_size ( ) const
inlinevirtual

<

Returns
number of frames in stack

Implements ers::Context.

Definition at line 99 of file LocalContext.hpp.

99{ return m_stack_size; }

◆ stack_symbols()

void *const * ers::LocalContext::stack_symbols ( ) const
inlinevirtual

<

Returns
stack frames

Implements ers::Context.

Definition at line 97 of file LocalContext.hpp.

97{ return m_stack; }

◆ thread_id()

pid_t ers::LocalContext::thread_id ( ) const
inlinevirtual

<

Returns
thread id

Implements ers::Context.

Definition at line 95 of file LocalContext.hpp.

95{ return m_thread_id; }

◆ user_id()

int ers::LocalContext::user_id ( ) const
inlinevirtual

<

Returns
user id

Implements ers::Context.

Definition at line 101 of file LocalContext.hpp.

101{ return c_process.m_uid; }

◆ user_name()

const char * ers::LocalContext::user_name ( ) const
inlinevirtual

<

Returns
user name

Implements ers::Context.

Definition at line 103 of file LocalContext.hpp.

103{ return c_process.m_uname; }
const char *const m_uname

Member Data Documentation

◆ c_process

const ers::LocalProcessContext ers::LocalContext::c_process
staticprivate

Definition at line 110 of file LocalContext.hpp.

◆ m_file_name

const char* const ers::LocalContext::m_file_name
private

source file-name

Definition at line 113 of file LocalContext.hpp.

◆ m_function_name

const char* const ers::LocalContext::m_function_name
private

source function name

Definition at line 114 of file LocalContext.hpp.

◆ m_line_number

const int ers::LocalContext::m_line_number
private

source line-number

Definition at line 115 of file LocalContext.hpp.

◆ m_package_name

const char* const ers::LocalContext::m_package_name
private

source package name

Definition at line 112 of file LocalContext.hpp.

◆ m_stack

void* ers::LocalContext::m_stack[64]
private

stack frames

Definition at line 117 of file LocalContext.hpp.

◆ m_stack_size

const int ers::LocalContext::m_stack_size
private

stack frames number

Definition at line 118 of file LocalContext.hpp.

◆ m_thread_id

const pid_t ers::LocalContext::m_thread_id
private

thread id

Definition at line 116 of file LocalContext.hpp.


The documentation for this class was generated from the following files: