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 Contextclone () 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 49 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 76 of file LocalContext.cpp.

87 m_stack_size( debug ? backtrace( m_stack, std::size(m_stack) ) : 0)
88{ ; }
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:74

◆ ~LocalContext()

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

Definition at line 66 of file LocalContext.hpp.

67 { ; }

Member Function Documentation

◆ application_name()

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

Implements ers::Context.

Definition at line 91 of file LocalContext.cpp.

92{
93 static int pid = ::getpid();
94 static const char * env = ::getenv( "DUNEDAQ_APPLICATION_NAME" ) ? ::getenv( "DUNEDAQ_APPLICATION_NAME" ) : "Undefined";
95
96 if (pid != ::getpid()) {
97 pid = ::getpid();
98 env = ::getenv( "DUNEDAQ_APPLICATION_NAME" ) ? ::getenv( "DUNEDAQ_APPLICATION_NAME" ) : "Undefined";
99 }
100 return env;
101}

◆ clone()

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

<

Returns
copy of the current context

Implements ers::Context.

Definition at line 69 of file LocalContext.hpp.

70 { 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 72 of file LocalContext.hpp.

73 { 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 75 of file LocalContext.hpp.

76 { 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 78 of file LocalContext.hpp.

79 { return m_function_name; }

◆ host_name()

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

<

Returns
host where the process is running

Implements ers::Context.

Definition at line 81 of file LocalContext.hpp.

82 { 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 84 of file LocalContext.hpp.

85 { return m_line_number; }

◆ package_name()

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

<

Returns
CMT package name

Implements ers::Context.

Definition at line 87 of file LocalContext.hpp.

88 { return m_package_name; }

◆ process_id()

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

<

Returns
process id

Implements ers::Context.

Definition at line 90 of file LocalContext.hpp.

91 { return ::getpid(); }

◆ resetProcessContext()

static 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.

100 { return m_stack_size; }

◆ stack_symbols()

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

<

Returns
stack frames

Implements ers::Context.

Definition at line 96 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 93 of file LocalContext.hpp.

94 { return m_thread_id; }

◆ user_id()

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

<

Returns
user id

Implements ers::Context.

Definition at line 102 of file LocalContext.hpp.

103 { return c_process.m_uid; }

◆ user_name()

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

<

Returns
user name

Implements ers::Context.

Definition at line 105 of file LocalContext.hpp.

106 { 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 113 of file LocalContext.hpp.

◆ m_file_name

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

source file-name

Definition at line 116 of file LocalContext.hpp.

◆ m_function_name

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

source function name

Definition at line 117 of file LocalContext.hpp.

◆ m_line_number

const int ers::LocalContext::m_line_number
private

source line-number

Definition at line 118 of file LocalContext.hpp.

◆ m_package_name

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

source package name

Definition at line 115 of file LocalContext.hpp.

◆ m_stack

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

stack frames

Definition at line 120 of file LocalContext.hpp.

◆ m_stack_size

const int ers::LocalContext::m_stack_size
private

stack frames number

Definition at line 121 of file LocalContext.hpp.

◆ m_thread_id

const pid_t ers::LocalContext::m_thread_id
private

thread id

Definition at line 119 of file LocalContext.hpp.


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