A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/logging_8cpp_source.html below:

NCBI C++ ToolKit: src/app/netcache/logging.cpp Source File

94 static const char

*

s_SevNames

[] = {

"Trace"

,

"Info"

,

"Warning"

,

"Error"

,

"Critical"

,

"Fatal"

,

"Fatal"

,

NULL

};

174  Int8

uid = (h << 48) |

175

((pid & 0xFFFF) << 32) |

176

((

Int8

(

t

) & 0xFFFFFFF) << 4) |

183  if

(

s_Pid

.size() < 5)

196

S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);

246  char

* old_buf =

data

->buf;

247  char

* old_msg_ptr =

data

->cur_msg_ptr;

248  size_t

old_msg_size =

data

->cur_ptr -

data

->cur_msg_ptr;

250  if

(old_msg_size != 0 &&

data

->buf) {

251

memcpy(

data

->buf, old_msg_ptr, old_msg_size);

252  data

->cur_ptr += old_msg_size;

262  data

->prefix.append(1,

'/'

);

264  if

(

data

->tmp_str.size() < 3)

265  data

->prefix.append(3 -

data

->tmp_str.size(),

'0'

);

266  data

->prefix.append(

data

->tmp_str.data(),

data

->tmp_str.size());

267  data

->prefix.append(1,

'/'

);

273  if

(

data

->cur_ptr + need_size >=

data

->end_ptr)

275  return data

->buf !=

nullptr

;

293

*

data

->cur_ptr++ = c ==

'\n'

?

';'

: c;

328

*

data

->cur_ptr++ =

' '

;

357  for

(

Uint1 i

= min_digs;

i

>

data

->tmp_str.size(); --

i

)

358

*

data

->cur_ptr++ =

'0'

;

377  if

(!diag_ctx &&

thr

&&

thr

->cur_task)

378

diag_ctx =

thr

->cur_task->m_DiagCtx;

380  Uint8

req_id = diag_ctx? diag_ctx->GetRequestID()

386

*

data

->cur_ptr++ =

' '

;

390

*

data

->cur_ptr++ =

'/'

;

392

*

data

->cur_ptr++ =

' '

;

400

*

data

->cur_ptr++ =

' '

;

403

*

data

->cur_ptr++ =

' '

;

409

*

data

->cur_ptr++ =

' '

;

415

*

data

->cur_ptr++ =

' '

;

418

*

data

->cur_ptr++ =

' '

;

427  if

(

data

->has_params)

428

*

data

->cur_ptr++ =

'&'

;

430  data

->has_params =

true

;

432

*

data

->cur_ptr++ =

'='

;

440  data

->last_flush_time = 0;

473

NCBI_NORETURN

static void 482  for

(

int

attempt=0; attempt<500 && cnt_halted != cnt_need; ++attempt) {

530

reg->

GetString

(section,

"log_thread_buf_size"

,

"10 MB"

));

533  string

vis = reg->

GetString

(section,

"log_visible"

,

"Warning"

);

541  string tmp

= reg->

GetString

(section,

"soft_fatal_action"

,

"abort"

);

564  string

is(

"\": "

), iss(

"\": \""

), eol(

",\n\""

);

610  if

(

thr

->thread_num == 0) {

631  data

->last_flush_time = cur_time;

648  else if

(

data

->buf)

658  if

(

data

->cur_ptr !=

data

->buf) {

665 find_match

(

char

lsep,

char

rsep,

const char

* start,

const char

* stop)

667  if

(*(stop - 1) != rsep)

return

stop;

669  const char

* pos = stop - 2;

670  for

(; pos > start; pos--) {

674  else if

(*pos == lsep) {

675  if

(--balance == 0)

break

;

678  return

(pos <= start) ?

NULL

: pos;

682 str_rev_str

(

const char

* begin_str,

const char

* end_str,

const char

* str_search)

684  if

(begin_str ==

NULL

)

686  if

(end_str ==

NULL

)

688  if

(str_search ==

NULL

)

691  const char

* search_char = str_search + strlen(str_search);

692  const char

* cur_char = end_str;

698

}

while

(*cur_char != *search_char && cur_char != begin_str);

699  if

(*cur_char != *search_char)

702  while

(search_char != str_search);

710  if

(!func || *func ==

'\0'

)

714  size_t len

= strlen(func);

715  const char

* end_str =

find_match

(

'('

,

')'

,

718  if

(end_str == func +

len

) {

724

end_str =

find_match

(

'<'

,

'>'

, func, end_str);

729  const char

* start_str =

NULL

;

732  const char

* start_str_tmp =

str_rev_str

(func, end_str,

"::"

);

733  bool

has_class = start_str_tmp !=

NULL

;

734  if

(start_str_tmp !=

NULL

) {

735

start_str = start_str_tmp + 2;

738  if

(start_str_tmp !=

NULL

) {

739

start_str = start_str_tmp + 1;

743  const char

* cur_funct_name = (start_str ==

NULL

? func: start_str);

744  size_t

cur_funct_name_len = end_str - cur_funct_name;

745

func_name.

assign

(cur_funct_name, cur_funct_name_len);

749

end_str =

find_match

(

'<'

,

'>'

, func, start_str - 2);

751  const char

* cur_class_name = (start_str ==

NULL

? func: start_str + 1);

752  size_t

cur_class_name_len = end_str - cur_class_name;

753

class_name.

assign

(cur_class_name, cur_class_name_len);

763  if

(

data

->cur_msg_ptr ==

data

->cur_ptr) {

764  if

(

msg

->m_OldStyle) {

765  msg

->StartSrvLog(

data

->severity,

data

->msg_file,

769  SRV_FATAL

(

"Unrecognized CSrvDiagMsg style"

);

792  SRV_FATAL

(

"Unsupported severity: "

<< sev);

814  SRV_FATAL

(

"Unsupported severity: "

<< sev);

854  ctx

->StartRequest();

866  return ctx

->IsRunning();

914  const char

* func)

const 994  msg

.m_Data->err_code = err_code.

m_Code

;

1008  if

(CDiagContext::IsCtxRunning(

ctx

)) {

1009  SRV_FATAL

(

"Unexpected StartRequest call"

);

1011

CDiagContext::StartCtxRequest(

ctx

);

1012  ctx

->SetRequestStatus(200);

1094  if

(!CDiagContext::IsCtxRunning(

ctx

)) {

1095  SRV_FATAL

(

"Unexpected StopRequest call"

);

1116

CDiagContext::StopCtxRequest(

ctx

);

1206  ctx

->AddReference();

1215 #if __NC_MEMMAN_USE_STD_MALLOC 1226 #if __NC_MEMMAN_USE_STD_MALLOC 1231  Uint4

cnt_in_chain = mem_cap;

1233  if

(--cnt_in_chain == 0) {

1237  if

(cnt_in_chain == mem_cap) {

1240 #if __NC_MEMMAN_USE_STD_MALLOC 1256  ctx

->SetRequestID();

1269 #if __NC_MEMMAN_USE_STD_MALLOC 1274  Uint4

cnt_in_chain = mem_cap;

1276  if

(--cnt_in_chain == 0) {

1284  if

(cnt_in_chain != 0)

1294

m_StrCurrFunctName(0)

1299  const char

* curr_funct)

1302

m_CurrFunctName(curr_funct),

1305

m_StrCurrFunctName(0)

1315  const string

& curr_funct,

1316  const string

& module)

1319

m_CurrFunctName(

""

),

1322

m_StrCurrFunctName(0)

1324  if

( !

file

.empty() ) {

1329  if

( !curr_funct.empty() ) {

1357

os << setfill(

' '

) << setw(13)

1358

<< setiosflags(IOS_BASE::left) << setw(0)

1360

<< resetiosflags(IOS_BASE::left)

1364  if

(err_code || err_subcode || err_text) {

1366

os <<

'('

<< err_text <<

')'

;

1368

os <<

'('

<< err_code <<

'.'

<< err_subcode <<

')'

;

1376  const char

* x_file;

1379

os <<

'"'

<<

string

(x_file, x_file_len) <<

'"'

;

1382

os <<

"\"UNK_FILE\""

;

1385

os <<

", line "

<< line;

1389  bool

print_loc = (nclass && *nclass ) || (func && *func);

1392  if

(nclass && *nclass) {

1396  if

(func && *func) {

1397

os << func <<

"() "

;

1407  if

(prefix && *prefix)

1408

os <<

'['

<< prefix <<

"] "

;

1424 #if __NC_TASKS_MONITOR 1425

m_TaskName =

"CLogWriter"

;

1442 #ifdef NCBI_OS_LINUX

Wrapper around Linux's futex.

EWaitResult WaitValueChange(int old_value)

Wait for futex's value to change (with and without timeout).

int GetValue(void)

Read value of the futex.

int WakeUpWaiters(int cnt_to_wake)

Wake up some threads waiting on this futex.

int AddValue(int cnt_to_add)

Atomically add some amount to futex's value.

virtual ~CLogWriter(void)

virtual void ExecuteSlice(TSrvThreadNum thr_num)

This is the main method to do all work this task should do.

Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilit...

void Unlock(void)

Unlock the mutex.

void Lock(void)

Lock the mutex.

Class used in all diagnostic logging.

const CSrvDiagMsg & StartSrvLog(ESeverity sev, const char *file, int line, const char *func) const

Starts log message which will include severity, filename, line number and function name.

CSrvDiagMsg & PrintExtra(void)

Starts "extra" message.

const CSrvDiagMsg & operator<<(CTempString str) const

Converts input value to string and adds to started log message.

CSrvDiagMsg & StartRequest(void)

Starts "request-start" message.

CSrvDiagMsg & PrintParam(CTempString name, CTempString value)

Adds parameter to "request-start" or "extra" message.

SLogData * m_Data

Log data from current thread.

SSrvThread * m_Thr

Current thread created this object.

bool m_OldStyle

Flag showing if "old style" message was started.

const CSrvDiagMsg & StartInfo(void) const

Starts informational message which doesn't need to have filename, line number or function name.

void StopRequest(void)

Prints "request-stop" message.

void Flush(void)

Finishes current message and prepare to start new one.

static bool IsSeverityVisible(ESeverity sev)

Checks if given severity level is visible, i.e.

const CSrvDiagMsg & StartOldStyle(const char *file, int line, const char *func)

Starts the "old style" log message.

ESeverity

Severity levels for logging.

Task controlling a socket.

CSrvSocketTask & WriteText(CTempString message)

Write text into socket.

CSrvSocketTask & WriteNumber(NumType num)

Write number into socket as string, i.e.

CSrvSocketTask & WriteBool(bool b)

Main working entity in TaskServer.

void SetDiagCtx(CRequestContext *ctx)

Set diagnostic context for this task to work in.

CRequestContext ** m_DiagChain

Nested diagnostic contexts of this task.

CRequestContext * m_DiagCtx

Current diagnostic context for this task.

void SetRunnable(bool boost=false)

Set this task "runnable", i.e.

void ReleaseDiagCtx(void)

Releases current diagnostic context of the task.

void CreateNewDiagCtx(void)

Create new diagnostic context for this task to work in.

Class incorporating convenient methods to work with struct timespec.

static int CurSecs(void)

Current time in seconds since epoch (time_t).

time_t & Sec(void)

Read/set number of seconds since epoch stored in the object.

static CSrvTime Current(void)

Exact current time with precision up to nanoseconds.

Uint1 Print(char *buf, EFormatType fmt) const

Formats time value in the object and writes it in buf.

long & NSec(void)

Read/set number of nanoseconds stored in the object.

@ eFmtLogging

Format used in logs which is YYYY-MM-DDThh:mm:ss.ssssss.

static const string & GetHostName(void)

Returns name of server this application is executing on.

static void RequestShutdown(ESrvShutdownType shutdown_type)

Asks server to start shutdown procedures.

static CSrvTime GetStartTime(void)

Returns time when this server application was started (when Initialize() method was called).

CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...

static const char * str(char *buf, int n)

#define ITERATE(Type, Var, Cont)

ITERATE macro to sequence through container elements.

void Write(string &str, TDiagWriteFlags flags=fNone) const

Binary OR of "EDiagWriteFlags".

void ParseCurrFunctName(void) const

int m_Code

Major error code number.

string m_StrCurrFunctName

string GetEncodedSessionID(void) const

Get url-encoded session id.

CDiagContext & GetDiagContext(void)

Get diag context instance.

static bool UpdatePID(void)

Reset PID cache (e.g. after fork). Return true if PID was updated.

static TCount GetNextRequestID(void)

Return the next available application-wide request ID.

static void UpdateOnFork(TOnForkFlags flags)

Update diagnostics after fork().

EDiagSev

Severity level for the posted diagnostics.

const char * m_CurrFunctName

string GetDefaultSessionID(void) const

Get default session id.

int m_SubCode

Minor error code number.

CDiagCompileInfo(void)

CDiagCompileInfo::

@ fNoEndl

No end of line.

@ eDiag_Trace

Trace message.

@ eDiag_Info

Informational message.

@ eDiag_Error

Error message.

@ eDiag_Warning

Warning message.

@ eDiag_Fatal

Fatal error – guarantees exit(or abort)

@ eDiag_Critical

Critical error message.

void Critical(CExceptionArgs_Base &args)

void Error(CExceptionArgs_Base &args)

void Trace(CExceptionArgs_Base &args)

void Warning(CExceptionArgs_Base &args)

void Fatal(CExceptionArgs_Base &args)

void Info(CExceptionArgs_Base &args)

static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)

Normalize a path.

static bool IsAbsolutePath(const string &path)

Check if a "path" is absolute for the current OS.

static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)

Assemble a path from basic components.

static string ConcatPath(const string &first, const string &second)

Concatenate two parts of the path for the current OS.

static string GetCwd(void)

Get the current working directory.

void RemoveReference(void) const

Remove reference to object.

uint8_t Uint1

1-byte (8-bit) unsigned integer

uint32_t Uint4

4-byte (32-bit) unsigned integer

int64_t Int8

8-byte (64-bit) signed integer

uint64_t Uint8

8-byte (64-bit) unsigned integer

static TPid GetPid(void)

Get process identifier (pid) for the current process.

virtual bool GetBool(const string &section, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const

Get boolean value of specified parameter name.

virtual int GetInt(const string &section, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const

Get integer value of specified parameter name.

virtual string GetString(const string &section, const string &name, const string &default_value, TFlags flags=0) const

Get the parameter string value.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

IO_PREFIX::ostream CNcbiOstream

Portable alias for ostream.

static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)

Convert Int8 to string.

static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)

Convert double to string.

static Uint8 StringToUInt8_DataSize(const CTempString str, TStringToNumFlags flags=0)

Convert string that can contain "software" qualifiers to Uint8.

CTempString & assign(const char *src_str, size_type len)

Assign new values to the content of the a string.

static void PtrToString(string &out_str, const void *ptr)

Convert pointer to string.

const char * data(void) const

Return a pointer to the array represented.

static bool NeedsURLEncoding(const CTempString str, EUrlEncode flag=eUrlEnc_SkipMarkChars)

Check if the string needs the requested URL-encoding.

static string URLEncode(const CTempString str, EUrlEncode flag=eUrlEnc_SkipMarkChars)

URL-encode string.

size_type size(void) const

Return the length of the represented array.

static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)

Convert UInt8 to string.

long GetNanoSecondsAfterSecond(void) const

Get number of nanoseconds.

long GetCompleteSeconds(void) const

Get number of complete seconds.

unsigned int

A callback function used to compare two keys in a database.

static void s_InitConstants(void)

static string s_UnkSession

static void s_ParseFuncName(const char *func, CTempString &class_name, CTempString &func_name)

static bool s_CheckBufSize(SLogData *data, size_t need_size)

static const char * s_SevNames[]

static list< CTempString > s_WriteQueue

void AssignThreadLogging(SSrvThread *thr)

static bool s_NeedFatalHalt

static SLogData * s_AllocNewData(TSrvThreadNum thr_num)

string GetLogFileName(void)

void SaveAppCmdLine(const string &cmd_line)

static CLogWriter * s_LogWriter

void CheckLoggingFlush(SSrvThread *thr)

static bool s_CheckOldStyleStart(const CSrvDiagMsg *msg)

void LogNoteThreadsStarted(void)

static bool s_FileNameInitialized

void ReleaseThreadLogging(SSrvThread *thr)

static void s_WriteLog(const char *buf, size_t size)

static bool s_LogRequests

static void s_AddLogPrefix(SSrvThread *thr, SLogData *data, CRequestContext *diag_ctx=NULL)

static Uint8 s_ProcessPostNum

static void s_AllocNewBuf(SLogData *data, size_t buf_size)

static void s_AddToLog(SLogData *data, const char *str, size_t size)

void ConfigureLogging(const CNcbiRegistry *reg, CTempString section)

static CFutex s_CntHaltedThreads

static void s_InitLogPrefix(SLogData *data, TSrvThreadNum thr_num)

string GetSoftFatalAction(void)

void WriteSetup_Logging(CSrvSocketTask &task)

void FinalizeLogging(void)

void Logging_DiskSpaceAlert(void)

static void s_QueueLogWrite(char *buf, size_t size)

static void s_InitFileName(void)

static size_t s_LogBufSize

void StartThreadLogging(SSrvThread *thr)

static CSrvDiagMsg::ESeverity s_ConvertSeverity(EOldStyleSeverity sev)

static bool s_ThreadsStarted

static bool s_DiskSpaceAlert

static void s_AddParamName(SLogData *data, CTempString name)

static SLogData * s_MainData

void SetLogFileName(CTempString name)

static void s_AddToLogStripLF(SLogData *data, const char *str, size_t size)

static void s_RotateLogBuf(SLogData *data)

static CSrvDiagMsg::ESeverity s_VisibleSev

static const char * str_rev_str(const char *begin_str, const char *end_str, const char *str_search)

static void s_DoFatalAbort(SLogData *data)

bool ReConfig_Logging(const CTempString &section, const CNcbiRegistry &new_reg, string &)

static int s_LastReopenTime

static void s_CheckFatalAbort(void)

string GetLogVisibility(void)

static const size_t kInitLogBufSize

static CMiniMutex s_WriteQueueLock

void StopThreadLogging(SSrvThread *thr)

static int s_FileReopenPeriod

static int s_MaxFlushPeriod

const CSrvDiagMsg & operator<<(const CSrvDiagMsg &msg, EOldStyleSeverity sev)

static string s_UnkClient

static const char * s_SoftFatalActions[]

static void s_AllocMainData(void)

static void s_OpenLogFile(void)

bool IsLongCommand(Uint8 cmd_len)

static const char * find_match(char lsep, char rsep, const char *start, const char *stop)

static const size_t kOneRecReserve

size_t GetMemSize(void *ptr)

const struct ncbi::grid::netcache::search::fields::SIZE size

const GenericPointer< typename T::ValueType > T2 value

Common macro to detect used sanitizers and suppress memory leaks if run under LeakSanitizer.

#define NCBI_CLANG_ANALYZER_SUPPRESS

Suppress clang analyzer report.

Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...

Multi-threading – mutexes; rw-locks; semaphore.

Process information in the NCBI Registry, including working with configuration files.

Defines CRequestContext class for NCBI C++ diagnostic API.

void ExtractFileName(const char *file, const char *&file_name, size_t &name_size)

static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

TSrvThreadNum s_MaxRunningThreads

T AtomicAdd(T volatile &var, T add_value)

constexpr Uint8 kUSecsPerMSec

CSrvDiagMsg::ESeverity severity

Uint2 TSrvThreadNum

Type for thread number in TaskServer.

CRef< CTestThread > thr[k_NumThreadsMax]

TSrvThreadNum GetCntRunningThreads(void)

SSrvThread * GetCurThread(void)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4