NCBI C++ ToolKit
Classes | Macros | Functions | Variables
ncbi_c_log.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "ncbi_c_log_p.h"
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <sys/errno.h>
#include <pthread.h>
#include <assert.h>
+ Include dependency graph for ncbi_c_log.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  TNcbiLog_MTLock_tag
 

Macros

#define NCBI_WIN32_THREADS
 
#define TROUBLE   s_Abort(__LINE__, 0)
 
#define TROUBLE_MSG(msg)   s_Abort(__LINE__, msg)
 
#define verify(expr)   assert(expr)
 
#define VERIFY(expr)   do { if ( !(expr) ) s_Abort(__LINE__, #expr); s_ReportError(__LINE__, #expr); } while ( 0 )
 
#define VERIFY_CATCH(expr)   do { if ( !(expr) ) { s_Abort(__LINE__, #expr); goto __catch_error; } } while ( 0 )
 
#define CATCH   __catch_error
 
#define UNUSED_ARG(x)   x##_UNUSED
 
#define min_value(a, b)   ((a) < (b) ? (a) : (b))
 
#define DIR_SEPARATOR   '\\'
 
#define UNKNOWN_HOST   "UNK_HOST"
 
#define UNKNOWN_CLIENT   "UNK_CLIENT"
 
#define UNKNOWN_SESSION   "UNK_SESSION"
 
#define UNKNOWN_HITID   ""
 
#define UNKNOWN_APPNAME   "UNK_APP"
 
#define kMTLock_magic_number   0x4C0E681F
 
#define MT_LOCK_VALID    if (sx_MTLock) assert(sx_MTLock->magic_number == kMTLock_magic_number)
 
#define MT_LOCK_Do(action)   (sx_MTLock ? s_MTLock_Do((action)) : -1)
 
#define MT_INIT   verify(MT_LOCK_Do(eNcbiLog_MT_Init) != 0)
 
#define MT_LOCK   verify(MT_LOCK_Do(eNcbiLog_MT_Lock) != 0)
 
#define MT_UNLOCK   verify(MT_LOCK_Do(eNcbiLog_MT_Unlock) != 0)
 
#define MT_DESTROY   verify(MT_LOCK_Do(eNcbiLog_MT_Destroy) != 0)
 
#define MT_LOCK_API
 
#define CHECK_APP_START(ctx)
 
#define kIdBufSize   128
 

Functions

static void s_Abort (long line, const char *msg)
 
static void s_ReportError (long line, const char *msg)
 
int NcbiLog_Default_MTLock_Handler (void *user_data_UNUSED, ENcbiLog_MTLock_Action action)
 Default implementation of simple MT locking callback. More...
 
static int s_MTLock_Do (ENcbiLog_MTLock_Action action)
 
TNcbiLog_MTLock NcbiLog_MTLock_Create (void *user_data, FNcbiLog_MTLock_Handler handler)
 Create new MT lock. More...
 
void NcbiLog_MTLock_Delete (TNcbiLog_MTLock lock)
 Call cleanup action on the handler, then destroy it. More...
 
static void s_TlsInit (void)
 
static void s_TlsDestroy (void)
 
static void * s_TlsGetValue (void)
 
static void s_TlsSetValue (void *ptr)
 
static void s_AppStart (TNcbiLog_Context ctx, const char *argv[])
 Print "start" message. More...
 
static void s_Extra (TNcbiLog_Context ctx, const SNcbiLog_Param *params)
 
static void s_ExtraStr (TNcbiLog_Context ctx, const char *params)
 
void s_SleepMicroSec (unsigned long mc_sec)
 Sleep the specified number of microseconds. More...
 
static char * s_StrDup (const char *str)
 strdup() doesn't exists on all platforms, and we cannot check this here. More...
 
static const char * s_ConcatPathEx (const char *p1, size_t p1_len, const char *p2, size_t p2_len, char *dst, size_t dst_size)
 Concatenate two parts of the path for the current OS. More...
 
static const char * s_ConcatPath (const char *p1, const char *p2, char *dst, size_t dst_size)
 Concatenate two parts of the path (zero-terminated strings) for the current OS. More...
 
const char * NcbiLog_GetHostName (void)
 Get host name. More...
 
static const char * s_ReadFileString (const char *filename)
 Read first string from specified file. More...
 
const char * NcbiLog_GetHostRole (void)
 Get host role string. More...
 
const char * NcbiLog_GetHostLocation (void)
 Get host location string. More...
 
static TNcbiLog_PID s_GetPID (void)
 Get current process ID. More...
 
static TNcbiLog_TID s_GetTID (void)
 Get current thread ID. More...
 
static TNcbiLog_UInt8 s_CreateUID (void)
 Create unique process ID. More...
 
static int s_GetTimeT (time_t *time_sec, unsigned long *time_ns)
 Update current UID with new timestamp. More...
 
static int s_GetTime (STime *t)
 Get current GMT time with nanoseconds (STime version) More...
 
static double s_DiffTime (const STime time_start, const STime time_end)
 Get time difference, time_end >- time_start. More...
 
static int s_GetTimeStr (char *buf, time_t time_sec, unsigned long time_ns)
 Get current local time in format 'YYYY-MM-DDThh:mm:ss.sss'. More...
 
static const char * s_GetClient_Env (void)
 This routine is called during start up and again in NcbiLog_ReqStart(). More...
 
const char * NcbiLogP_GetSessionID_Env (void)
 This routine is called during start up and again in NcbiLog_ReqStart(). More...
 
const char * NcbiLogP_GetHitID_Env (void)
 This routine is called during start up and again in NcbiLog_ReqStart(). More...
 
int NcbiLogP_GetEnv_UInt (const char *env_var_name, unsigned int *value)
 Get value from numeric-based environment variables. More...
 
static void s_URL_Encode (const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)
 URL-encode up to "src_size" symbols(bytes) from buffer "src_buf". More...
 
static void s_EscapeNewlines (const void *src_buf, size_t src_size, size_t *src_read, void *dst_buf, size_t dst_size, size_t *dst_written)
 Escape newlines in the string. More...
 
static char * s_GetAppBaseName (const char *path)
 Get base name of application. More...
 
static TNcbiLog_Context s_CreateContext (void)
 Create thread-specific context. More...
 
static int s_AttachContext (TNcbiLog_Context ctx)
 Attach thread-specific context. More...
 
static TNcbiLog_Context s_GetContext (void)
 Get pointer to the thread-specific context. More...
 
static void s_DestroyContext (void)
 Destroy thread-specific context. More...
 
static const char * s_GetToolkitRCLogLocation ()
 Determine logs location on the base of TOOLKITRC_FILE. More...
 
static void s_CloseLogFiles (int cleanup)
 Close log files for a current destination. More...
 
static int s_OpenLogFiles (void)
 Open file streams. More...
 
static int s_SetLogFiles (const char *path_with_base_name, int is_applog)
 (Re)Initialize logging file streams. More...
 
static int s_SetLogFilesDir (const char *dir, int is_applog)
 (Re)Initialize logging file streams. More...
 
static void s_InitDestination (const char *logfile_path)
 (Re)Initialize destination. More...
 
static void s_SetHost (const char *host)
 
static void s_SetClient (char *dst, const char *client)
 
static void s_SetSession (char *dst, const char *session)
 
static void s_SetHitID (char *dst, const char *hit_id)
 
static int s_IsInsideRequest (TNcbiLog_Context ctx)
 
static char * s_GenerateSID_Str_Ex (char *dst, int use_logging_api, TNcbiLog_UInt8 uid)
 
static char * s_GenerateSID_Str (char *dst)
 
static char * s_GenerateHitID_Str_Ex (char *dst, int is_api_call, TNcbiLog_UInt8 uid)
 
static char * s_GenerateHitID_Str (char *dst)
 
TNcbiLog_UInt8 NcbiLogP_GenerateUID (void)
 Generate new unique process ID. More...
 
const char * NcbiLogP_GenerateHitID (char *buf, size_t n, TNcbiLog_UInt8 uid)
 Generate new Hit ID string. More...
 
const char * NcbiLogP_GenerateSID (char *buf, size_t n, TNcbiLog_UInt8 uid)
 Generate new SID string. More...
 
static size_t s_Write (int fd, const void *buf, size_t count)
 
static void s_Post (TNcbiLog_Context ctx, ENcbiLog_DiagFile diag)
 Post prepared message into the log. More...
 
static size_t s_PrintCommonPrefix (TNcbiLog_Context ctx)
 Print common prefix to message buffer. More...
 
static int s_AddParamsPair (SNcbiLog_Param params[], int index, const char *key, const char *value)
 Add parameters pair to the list if not empty. More...
 
static size_t s_PrintParamsPair (char *dst, size_t pos, const char *key, const char *value)
 Print one parameter's pair (key, value) to message buffer. More...
 
static size_t s_PrintParams (char *dst, size_t pos, const SNcbiLog_Param *params)
 Print parameters to message buffer. More...
 
static size_t s_PrintParamsStr (char *dst, size_t pos, const char *params)
 Print parameters to message buffer (string version). More...
 
static void s_PrintMessage (ENcbiLog_Severity severity, const char *msg, int print_as_note)
 Print a message with severity to message buffer. More...
 
static void s_Init (const char *appname)
 
void NcbiLog_Init (const char *appname, TNcbiLog_MTLock mt_lock, ENcbiLog_MTLock_Ownership mt_lock_ownership)
 Initializing NcbiLog API. More...
 
void NcbiLog_InitMT (const char *appname)
 Version of NcbiLog_Init with default MT lock implementation. More...
 
void NcbiLog_InitST (const char *appname)
 Version of NcbiLog_Init to use in single-threaded applications. More...
 
void NcbiLog_InitForAttachedContext (const char *appname)
 Version of NcbiLog_Init to use with NcbiLog_Context_* functions only. More...
 
void NcbiLog_InitForAttachedContextST (const char *appname)
 Version of NcbiLog_InitForAttachedContext() intended to use in single-threaded applications. More...
 
void NcbiLog_Destroy_Thread (void)
 Destroy thread-specific NcbiLog API information. More...
 
void NcbiLog_Destroy (void)
 Destroy NcbiLog API. More...
 
void NcbiLogP_ReInit (void)
 
TNcbiLog_Context NcbiLog_Context_Create (void)
 Create new thread-specific logging context object. More...
 
int NcbiLog_Context_Attach (TNcbiLog_Context ctx)
 Attach logging context object to the C Logging API. More...
 
void NcbiLog_Context_Detach (void)
 Detach logging context object from the C Logging API. More...
 
void NcbiLog_Context_Destroy (TNcbiLog_Context ctx)
 Destroy context structure. More...
 
static void s_SetState (TNcbiLog_Context ctx, ENcbiLog_AppState state)
 Set application state – internal version without MT locking. More...
 
ENcbiLog_Destination NcbiLog_SetDestination (ENcbiLog_Destination ds)
 Set up diagnostics destination. More...
 
ENcbiLog_Destination NcbiLog_SetDestinationFile (const char *logfile_base)
 Variant of NcbiLog_SetDestination for logging to a specific file (eNcbiLog_File). More...
 
ENcbiLog_Destination NcbiLogP_SetDestination (ENcbiLog_Destination ds, unsigned int port, const char *logsite)
 Variant of NcbiLog_SetDestination. More...
 
void NcbiLog_SetSplitLogFile (int value)
 Set split log files flag. More...
 
void NcbiLog_SetProcessId (TNcbiLog_PID pid)
 Set process ID (PID). More...
 
void NcbiLog_SetThreadId (TNcbiLog_TID tid)
 Set thread ID (TID). More...
 
void NcbiLog_SetRequestId (TNcbiLog_Counter rid)
 Set current request ID (RID). More...
 
TNcbiLog_Counter NcbiLog_GetRequestId (void)
 Get current request ID (RID). More...
 
void NcbiLog_SetTime (time_t time_sec, unsigned long time_ns)
 Set the posting date and time. More...
 
void NcbiLog_SetHost (const char *host)
 Set the host name. More...
 
void NcbiLog_AppSetClient (const char *client)
 Set client for the whole application. More...
 
void NcbiLog_SetClient (const char *client)
 Set client for the request. More...
 
void NcbiLog_AppSetSession (const char *session)
 Set session ID (SID) for the whole application. More...
 
char * NcbiLog_AppGetSession (void)
 Get session ID (SID) for the whole application. More...
 
char * NcbiLog_GetSession (void)
 Get sessio ID (SID) for the request. More...
 
void NcbiLog_SetSession (const char *session)
 Set session ID (SID) for the request. More...
 
void NcbiLog_AppNewSession (void)
 Auto-generate and then set brand-new application-wide session ID (SID). More...
 
void NcbiLog_NewSession (void)
 Auto-generate and then set brand-new session ID (SID) for the request. More...
 
static void s_LogHitID (TNcbiLog_Context ctx, const char *hit_id)
 
static void s_LogSubHitID (TNcbiLog_Context ctx, const char *subhit_id)
 
void NcbiLog_AppSetHitID (const char *hit_id)
 Set hit ID (HID, a.k.a. More...
 
void NcbiLog_SetHitID (const char *hit_id)
 Set hit ID (HID, a.k.a. More...
 
void NcbiLog_AppNewHitID (void)
 
void NcbiLog_NewHitID (void)
 
char * NcbiLog_AppGetHitID (void)
 Get hit ID (HID, a.k.a. More...
 
char * NcbiLog_GetHitID (void)
 Get hit ID (HID, a.k.a. More...
 
static char * s_GetSubHitID (TNcbiLog_Context ctx, int need_increment, const char *prefix)
 
char * NcbiLog_GetCurrentSubHitID (void)
 
char * NcbiLog_GetCurrentSubHitID_Prefix (const char *prefix)
 Get the last generated sub-hit ID. More...
 
char * NcbiLog_GetNextSubHitID (void)
 
char * NcbiLog_GetNextSubHitID_Prefix (const char *prefix)
 Generate a sub-hit ID based on the currently effective (whether it's request-specific or application-wide) hit ID. More...
 
void NcbiLog_FreeMemory (void *ptr)
 Free memory allocated inside the C logging API. More...
 
ENcbiLog_Severity NcbiLog_SetPostLevel (ENcbiLog_Severity sev)
 Set new posting severity threshold. More...
 
ENcbiLog_AppState NcbiLog_GetState (void)
 Get current logging execution state (context and thread specific). More...
 
void NcbiLog_AppStart (const char *argv[])
 Should be called as soon as possible during application initialization. More...
 
void NcbiLog_AppRun (void)
 Should be called after the application is initialized and before its main part. More...
 
void NcbiLog_AppStop (int exit_status)
 Should be called immediately prior to the application exit. More...
 
void NcbiLog_AppStopSignal (int exit_status, int exit_signal)
 The same as NcbiLog_AppStop(), except it also accepts a signal number, if application exited due to a signal. More...
 
void NcbiLogP_AppStop (int exit_status, int exit_signal, double execution_time)
 Should be called immediately prior to the application exit. More...
 
static size_t s_ReqStart (TNcbiLog_Context ctx)
 
static size_t s_PrintReqStartExtraParams (size_t pos)
 Print extra parameters for request start. More...
 
void NcbiLog_ReqStart (const SNcbiLog_Param *params)
 Should be called once application startup is complete, before any request processing code is run. More...
 
void NcbiLogP_ReqStartStr (const char *params)
 Variant of NcbiLog_ReqStart, that use already prepared string with parameters. More...
 
void NcbiLog_ReqRun (void)
 Should be called once request processing initialization is complete. More...
 
void NcbiLog_ReqStop (int status, size_t bytes_rd, size_t bytes_wr)
 Should be called once request processing is complete. More...
 
void NcbiLog_Extra (const SNcbiLog_Param *params)
 Can be called at any time. More...
 
void NcbiLogP_ExtraStr (const char *params)
 Variant of NcbiLog_Extra, that use already prepared string with parameters. More...
 
void NcbiLog_Perf (int status, double timespan, const SNcbiLog_Param *params)
 Can be called at any time. More...
 
void NcbiLogP_PerfStr (int status, double timespan, const char *params)
 Variant of NcbiLog_Perf, that use already prepared string with parameters. More...
 
void NcbiLog_Trace (const char *msg)
 Writes a message to the <appname>.trace file at level 'TRACE'. More...
 
void NcbiLog_Info (const char *msg)
 Writes a message to the <appname>.trace file at level 'INFO'. More...
 
void NcbiLog_Warning (const char *msg)
 Writes a message to the <appname>.err log at level 'WARNING'. More...
 
void NcbiLog_Error (const char *msg)
 Writes a message to the <appname>.err log at level 'ERROR'. More...
 
void NcbiLog_Critical (const char *msg)
 Writes a message to the <appname>.err log at level 'CRITICAL'. More...
 
void NcbiLog_Fatal (const char *msg)
 Writes a message to the <appname>.err log at level 'FATAL' and then terminate the application. More...
 
void NcbiLog_Note (ENcbiLog_Severity severity, const char *msg)
 Writes a message using "Note[X]" notation for severity. More...
 
void NcbiLogP_Raw (const char *line)
 Post already prepared line in applog format to the applog. More...
 
void NcbiLogP_Raw2 (const char *line, size_t len)
 Variant of NcbiLogP_Raw with already known line size to avoid double length calculation. More...
 
void NcbiLog_UpdateOnFork (TNcbiLog_OnForkFlags flags)
 Update logging internal information after fork(). More...
 
TNcbiLog_InfoNcbiLogP_GetInfoPtr (void)
 
TNcbiLog_Context NcbiLogP_GetContextPtr (void)
 
int NcbiLogP_DisableChecks (int disable)
 Enable/disable internal checks (enabled by default) Used by ncbi_applog. More...
 

Variables

static const char * kBaseLogDir = "/log/"
 
static volatile int sx_IsInit = 0
 
static volatile int sx_IsEnabled = 0
 
static volatile int sx_DisableChecks = 0
 
static volatile TNcbiLog_Infosx_Info = NULL
 
static volatile TNcbiLog_Context sx_ContextST = NULL
 
static volatile TNcbiLog_PID sx_PID = 0
 
static pthread_mutex_t sx_MT_handle = PTHREAD_MUTEX_INITIALIZER
 
static struct TNcbiLog_MTLock_tag sx_MTLock_Default = {NULL, NcbiLog_Default_MTLock_Handler, 0x4C0E681F }
 
static volatile TNcbiLog_MTLock sx_MTLock = &sx_MTLock_Default
 
static volatile int sx_MTLock_Own = 0
 
static volatile int sx_TlsIsInit = 0
 
static volatile pthread_key_t sx_Tls
 
static const unsigned char sx_EncodeTable [256][4]
 
static const char * sx_AppStateStr []
 
static const char * sx_SeverityStr []
 

Macro Definition Documentation

◆ CATCH

#define CATCH   __catch_error

Definition at line 131 of file ncbi_c_log.c.

◆ CHECK_APP_START

#define CHECK_APP_START (   ctx)
Value:
s_AppStart(ctx, NULL); \
}
CS_CONTEXT * ctx
Definition: t0006.c:12
#define NULL
Definition: ncbistd.hpp:225
@ eNcbiLog_NotSet
Reserved value, never used in messages.
Definition: ncbi_c_log.h:995
static volatile TNcbiLog_Info * sx_Info
Definition: ncbi_c_log.c:184
ENcbiLog_AppState state
Application state.
Definition: ncbi_c_log_p.h:135

Definition at line 474 of file ncbi_c_log.c.

◆ DIR_SEPARATOR

#define DIR_SEPARATOR   '\\'

Definition at line 144 of file ncbi_c_log.c.

◆ kIdBufSize

#define kIdBufSize   128

◆ kMTLock_magic_number

#define kMTLock_magic_number   0x4C0E681F

Definition at line 312 of file ncbi_c_log.c.

◆ min_value

#define min_value (   a,
  b 
)    ((a) < (b) ? (a) : (b))

◆ MT_DESTROY

#define MT_DESTROY   verify(MT_LOCK_Do(eNcbiLog_MT_Destroy) != 0)

Definition at line 344 of file ncbi_c_log.c.

◆ MT_INIT

#define MT_INIT   verify(MT_LOCK_Do(eNcbiLog_MT_Init) != 0)

Definition at line 341 of file ncbi_c_log.c.

◆ MT_LOCK

Definition at line 342 of file ncbi_c_log.c.

◆ MT_LOCK_API

#define MT_LOCK_API
Value:
while (!sx_IsEnabled) { \
/* Delays is possible only on the time of first Init() */ \
s_SleepMicroSec(10); \
} \
assert(sx_Info); \
MT_LOCK
static volatile int sx_IsEnabled
Definition: ncbi_c_log.c:178
static volatile int sx_IsInit
Definition: ncbi_c_log.c:175
#define assert(x)
Definition: srv_diag.hpp:58

Definition at line 462 of file ncbi_c_log.c.

◆ MT_LOCK_Do

#define MT_LOCK_Do (   action)    (sx_MTLock ? s_MTLock_Do((action)) : -1)

Definition at line 337 of file ncbi_c_log.c.

◆ MT_LOCK_VALID

#define MT_LOCK_VALID    if (sx_MTLock) assert(sx_MTLock->magic_number == kMTLock_magic_number)

Definition at line 327 of file ncbi_c_log.c.

◆ MT_UNLOCK

#define MT_UNLOCK   verify(MT_LOCK_Do(eNcbiLog_MT_Unlock) != 0)

Definition at line 343 of file ncbi_c_log.c.

◆ NCBI_WIN32_THREADS

#define NCBI_WIN32_THREADS

Definition at line 62 of file ncbi_c_log.c.

◆ TROUBLE

#define TROUBLE   s_Abort(__LINE__, 0)

Definition at line 87 of file ncbi_c_log.c.

◆ TROUBLE_MSG

#define TROUBLE_MSG (   msg)    s_Abort(__LINE__, msg)

Definition at line 88 of file ncbi_c_log.c.

◆ UNKNOWN_APPNAME

#define UNKNOWN_APPNAME   "UNK_APP"

Definition at line 159 of file ncbi_c_log.c.

◆ UNKNOWN_CLIENT

#define UNKNOWN_CLIENT   "UNK_CLIENT"

Definition at line 156 of file ncbi_c_log.c.

◆ UNKNOWN_HITID

#define UNKNOWN_HITID   ""

Definition at line 158 of file ncbi_c_log.c.

◆ UNKNOWN_HOST

#define UNKNOWN_HOST   "UNK_HOST"

Definition at line 155 of file ncbi_c_log.c.

◆ UNKNOWN_SESSION

#define UNKNOWN_SESSION   "UNK_SESSION"

Definition at line 157 of file ncbi_c_log.c.

◆ UNUSED_ARG

#define UNUSED_ARG (   x)    x##_UNUSED

Definition at line 136 of file ncbi_c_log.c.

◆ verify

#define verify (   expr)    assert(expr)

Definition at line 97 of file ncbi_c_log.c.

◆ VERIFY

#define VERIFY (   expr)    do { if ( !(expr) ) s_Abort(__LINE__, #expr); s_ReportError(__LINE__, #expr); } while ( 0 )

Definition at line 111 of file ncbi_c_log.c.

◆ VERIFY_CATCH

#define VERIFY_CATCH (   expr)    do { if ( !(expr) ) { s_Abort(__LINE__, #expr); goto __catch_error; } } while ( 0 )

Definition at line 117 of file ncbi_c_log.c.

Function Documentation

◆ NcbiLogP_AppStop()

void NcbiLogP_AppStop ( int  exit_status,
int  exit_signal,
double  execution_time 
)

Should be called immediately prior to the application exit.

Logs the 'stop' line to the <appname>.log files. Allow to set the application runtime directly, not based on a start and end time, if execution_time >= 0.

Used by ncbi_applog.

See also
NcbiLog_AppStop, NcbiLog_AppStopSignal

Definition at line 3412 of file ncbi_c_log.c.

References SInfo_tag::app_start_time, CATCH, CHECK_APP_START, ctx, eDiag_Log, eNcbiLog_AppEnd, SInfo_tag::message, MT_LOCK_API, MT_UNLOCK, NULL, SInfo_tag::post_time, s_DiffTime(), s_GetContext(), s_Post(), s_PrintCommonPrefix(), s_SetState(), sx_Info, and VERIFY_CATCH.

Referenced by NcbiLog_AppStop(), NcbiLog_AppStopSignal(), and CNcbiApplogApp::Run().

◆ NcbiLogP_DisableChecks()

int NcbiLogP_DisableChecks ( int  disable)

Enable/disable internal checks (enabled by default) Used by ncbi_applog.

Definition at line 4030 of file ncbi_c_log.c.

References sx_DisableChecks.

Referenced by CNcbiApplogApp::Run().

◆ NcbiLogP_ExtraStr()

void NcbiLogP_ExtraStr ( const char *  params)

Variant of NcbiLog_Extra, that use already prepared string with parameters.

Both, key and value in pairs 'key=value' should be URL-encoded and separated with '&'.

See also
NcbiLog_Extra

Definition at line 3727 of file ncbi_c_log.c.

References CHECK_APP_START, ctx, MT_LOCK_API, MT_UNLOCK, NULL, s_ExtraStr(), and s_GetContext().

Referenced by CNcbiApplogApp::Run().

◆ NcbiLogP_GenerateHitID()

const char* NcbiLogP_GenerateHitID ( char *  buf,
size_t  n,
TNcbiLog_UInt8  uid 
)

Generate new Hit ID string.

Return NULL on error.

Definition at line 2023 of file ncbi_c_log.c.

References buf, n, NCBILOG_HITID_MAX, NULL, and s_GenerateHitID_Str_Ex().

Referenced by CNcbiApplogApp::Cmd_Generate().

◆ NcbiLogP_GenerateSID()

const char* NcbiLogP_GenerateSID ( char *  buf,
size_t  n,
TNcbiLog_UInt8  uid 
)

Generate new SID string.

Return NULL on error.

Definition at line 2037 of file ncbi_c_log.c.

References buf, n, NCBILOG_SESSION_MAX, NULL, and s_GenerateSID_Str_Ex().

Referenced by CNcbiApplogApp::Cmd_Generate().

◆ NcbiLogP_GenerateUID()

TNcbiLog_UInt8 NcbiLogP_GenerateUID ( void  )

Generate new unique process ID.

Return 0 on error.

Definition at line 2015 of file ncbi_c_log.c.

References s_CreateUID().

Referenced by CNcbiApplogApp::Cmd_Generate().

◆ NcbiLogP_GetContextPtr()

TNcbiLog_Context NcbiLogP_GetContextPtr ( void  )

Definition at line 4025 of file ncbi_c_log.c.

References s_GetContext().

Referenced by CNcbiApplogApp::SetInfo(), and CNcbiApplogApp::UpdateInfo().

◆ NcbiLogP_GetEnv_UInt()

int NcbiLogP_GetEnv_UInt ( const char *  env_var_name,
unsigned int value 
)

Get value from numeric-based environment variables.

Get unsigned int value from a numeric-based environment variable.

Definition at line 953 of file ncbi_c_log.c.

References int, NULL, and rapidjson::value.

Referenced by s_Init().

◆ NcbiLogP_GetHitID_Env()

const char* NcbiLogP_GetHitID_Env ( void  )

This routine is called during start up and again in NcbiLog_ReqStart().

Get value of hit ID from the environment.

The received environment value will be cached for whole process.

Definition at line 931 of file ncbi_c_log.c.

References NULL, and s_StrDup().

Referenced by CNcbiApplogApp::Redirect(), CNcbiApplogApp::Run(), and s_AppStart().

◆ NcbiLogP_GetInfoPtr()

TNcbiLog_Info* NcbiLogP_GetInfoPtr ( void  )

Definition at line 4020 of file ncbi_c_log.c.

References sx_Info.

Referenced by CNcbiApplogApp::SetInfo(), and CNcbiApplogApp::UpdateInfo().

◆ NcbiLogP_GetSessionID_Env()

const char* NcbiLogP_GetSessionID_Env ( void  )

This routine is called during start up and again in NcbiLog_ReqStart().

Get value of session ID from the environment.

The received environment value will be cached for whole process.

Definition at line 908 of file ncbi_c_log.c.

References NULL, and s_StrDup().

Referenced by CNcbiApplogApp::Redirect(), CNcbiApplogApp::Run(), s_AppStart(), and s_ReqStart().

◆ NcbiLogP_PerfStr()

void NcbiLogP_PerfStr ( int  status,
double  timespan,
const char *  params 
)

Variant of NcbiLog_Perf, that use already prepared string with parameters.

Both, key and value in pairs 'key=value' should be URL-encoded and separated with '&'.

See also
NcbiLog_Perf

Definition at line 3782 of file ncbi_c_log.c.

References buf, CATCH, CHECK_APP_START, ctx, eDiag_Perf, SInfo_tag::message, MT_LOCK_API, MT_UNLOCK, NCBILOG_ENTRY_MAX, NULL, SInfo_tag::phid, s_GetContext(), s_IsInsideRequest(), s_Post(), s_PrintCommonPrefix(), s_PrintParamsPair(), s_PrintParamsStr(), sx_Info, and VERIFY_CATCH.

Referenced by CNcbiApplogApp::Run().

◆ NcbiLogP_Raw()

void NcbiLogP_Raw ( const char *  line)

Post already prepared line in applog format to the applog.

It do not perform any additional check and don' change context as well, just write specified line to applog as is. 'line' should not have EOLs, it will be automatically added.

Definition at line 3862 of file ncbi_c_log.c.

References assert, and NcbiLogP_Raw2().

◆ NcbiLogP_Raw2()

void NcbiLogP_Raw2 ( const char *  line,
size_t  n 
)

◆ NcbiLogP_ReInit()

void NcbiLogP_ReInit ( void  )

Definition at line 2638 of file ncbi_c_log.c.

References sx_IsInit.

◆ NcbiLogP_ReqStartStr()

void NcbiLogP_ReqStartStr ( const char *  params)

Variant of NcbiLog_ReqStart, that use already prepared string with parameters.

Both, key and value in pairs 'key=value' should be URL-encoded and separated with '&'.

See also
NcbiLog_ReqStart

Definition at line 3574 of file ncbi_c_log.c.

References CATCH, ctx, eDiag_Log, SInfo_tag::message, MT_LOCK_API, MT_UNLOCK, NCBILOG_ENTRY_MAX, NULL, prev(), s_GetContext(), s_Post(), s_PrintParamsStr(), s_PrintReqStartExtraParams(), s_ReqStart(), sx_Info, and VERIFY_CATCH.

Referenced by CNcbiApplogApp::Run().

◆ NcbiLogP_SetDestination()

ENcbiLog_Destination NcbiLogP_SetDestination ( ENcbiLog_Destination  ds,
unsigned int  port,
const char *  logsite 
)

Variant of NcbiLog_SetDestination.

Try to force set new destination without additional checks. The 'port' parameter redefine value of $SERVER_PORT environment variable. Use 0 if undefined. Can be used only for redirect mode. The 'logsite' parameter is used specifically by ncbi_applog utility, to allow to check additionally /log/<logsite> destination. See for details: http://ncbi.github.io/cxx-toolkit/pages/ch_log#ch_core.Where_Diagnostic_Messages_Go

See also
NcbiLog_SetDestination, ENcbiLog_Destination, NcbiLog_Init

Definition at line 2834 of file ncbi_c_log.c.

References SInfo_tag::destination, eNcbiLog_Default, eNcbiLog_Disable, eNcbiLog_Stderr, SInfo_tag::last_reopen_time, SInfo_tag::logsite, MT_LOCK_API, MT_UNLOCK, NULL, s_InitDestination(), SInfo_tag::server_port, util::strcmp(), and sx_Info.

Referenced by CNcbiApplogApp::Cmd_Health(), and CNcbiApplogApp::Run().

◆ s_Abort()

static void s_Abort ( long  line,
const char *  msg 
)
static

Definition at line 197 of file ncbi_c_log.c.

References abort(), and exit().

Referenced by s_PrintMessage().

◆ s_AddParamsPair()

static int s_AddParamsPair ( SNcbiLog_Param  params[],
int  index,
const char *  key,
const char *  value 
)
static

Add parameters pair to the list if not empty.

Update and return index. Because this method is for internal usage only, to print automatically logged extra parameters, neither key or value can be empty here.

Definition at line 2265 of file ncbi_c_log.c.

References assert, ncbi::grid::netcache::search::fields::key, SNcbiLog_Param::key, SNcbiLog_Param::value, and rapidjson::value.

Referenced by NcbiLog_AppRun(), s_LogHitID(), and s_LogSubHitID().

◆ s_AppStart()

static void s_AppStart ( TNcbiLog_Context  ctx,
const char *  argv[] 
)
static

◆ s_AttachContext()

static int s_AttachContext ( TNcbiLog_Context  ctx)
static

Attach thread-specific context.

Definition at line 1249 of file ncbi_c_log.c.

References ctx, prev(), s_TlsGetValue(), s_TlsSetValue(), sx_ContextST, and sx_TlsIsInit.

Referenced by NcbiLog_Context_Attach(), and s_GetContext().

◆ s_CloseLogFiles()

static void s_CloseLogFiles ( int  cleanup)
static

◆ s_ConcatPath()

static const char* s_ConcatPath ( const char *  p1,
const char *  p2,
char *  dst,
size_t  dst_size 
)
static

Concatenate two parts of the path (zero-terminated strings) for the current OS.

Definition at line 559 of file ncbi_c_log.c.

References s_ConcatPathEx().

Referenced by s_GetToolkitRCLogLocation(), and s_InitDestination().

◆ s_ConcatPathEx()

static const char* s_ConcatPathEx ( const char *  p1,
size_t  p1_len,
const char *  p2,
size_t  p2_len,
char *  dst,
size_t  dst_size 
)
static

Concatenate two parts of the path for the current OS.

Definition at line 529 of file ncbi_c_log.c.

References assert, DIR_SEPARATOR, n, and NULL.

Referenced by s_ConcatPath(), and s_SetLogFilesDir().

◆ s_CreateContext()

static TNcbiLog_Context s_CreateContext ( void  )
static

Create thread-specific context.

Definition at line 1234 of file ncbi_c_log.c.

References assert, ctx, malloc(), and s_GetTID().

Referenced by NcbiLog_Context_Create(), and s_GetContext().

◆ s_CreateUID()

static TNcbiLog_UInt8 s_CreateUID ( void  )
static

Create unique process ID.

Adapted from C++ Toolkit code: see CDiagContect::x_CreateUID().

Definition at line 708 of file ncbi_c_log.c.

References NcbiLog_GetHostName(), s_GetPID(), and t.

Referenced by NcbiLog_UpdateOnFork(), NcbiLogP_GenerateUID(), s_GenerateHitID_Str_Ex(), s_GenerateSID_Str_Ex(), and s_PrintCommonPrefix().

◆ s_DestroyContext()

static void s_DestroyContext ( void  )
static

Destroy thread-specific context.

Definition at line 1301 of file ncbi_c_log.c.

References ctx, free(), NULL, s_TlsGetValue(), s_TlsSetValue(), sx_ContextST, and sx_TlsIsInit.

Referenced by NcbiLog_Destroy(), and NcbiLog_Destroy_Thread().

◆ s_DiffTime()

static double s_DiffTime ( const STime  time_start,
const STime  time_end 
)
static

Get time difference, time_end >- time_start.

Definition at line 806 of file ncbi_c_log.c.

References STime_tag::ns, and STime_tag::sec.

Referenced by NcbiLog_ReqStop(), and NcbiLogP_AppStop().

◆ s_EscapeNewlines()

static void s_EscapeNewlines ( const void *  src_buf,
size_t  src_size,
size_t *  src_read,
void *  dst_buf,
size_t  dst_size,
size_t *  dst_written 
)
static

Escape newlines in the string.

Follow CXX-7439 applog standard newline replacement convention.


  • -> \v
  • \v -> 0xFF \v
  • 0xFF -> 0xFF 0xFF

This function read up to "src_size" symbols(bytes) from buffer "src_buf". Write the escaped data to buffer "dst_buf", but no more than "dst_size" bytes. Assign "*src_read" to the # of bytes successfully escaped from "src_buf". Assign "*dst_written" to the # of bytes written to buffer "dst_buf".

Definition at line 1144 of file ncbi_c_log.c.

Referenced by s_PrintMessage().

◆ s_Extra()

static void s_Extra ( TNcbiLog_Context  ctx,
const SNcbiLog_Param params 
)
static

◆ s_ExtraStr()

static void s_ExtraStr ( TNcbiLog_Context  ctx,
const char *  params 
)
static

◆ s_GenerateHitID_Str()

static char* s_GenerateHitID_Str ( char *  dst)
static

Definition at line 2007 of file ncbi_c_log.c.

References s_GenerateHitID_Str_Ex().

Referenced by NcbiLog_ReqRun(), and s_AppStart().

◆ s_GenerateHitID_Str_Ex()

static char* s_GenerateHitID_Str_Ex ( char *  dst,
int  is_api_call,
TNcbiLog_UInt8  uid 
)
static

◆ s_GenerateSID_Str()

static char* s_GenerateSID_Str ( char *  dst)
static

Definition at line 1963 of file ncbi_c_log.c.

References s_GenerateSID_Str_Ex().

Referenced by NcbiLog_AppNewSession(), NcbiLog_NewSession(), and s_ReqStart().

◆ s_GenerateSID_Str_Ex()

static char* s_GenerateSID_Str_Ex ( char *  dst,
int  use_logging_api,
TNcbiLog_UInt8  uid 
)
static

◆ s_GetAppBaseName()

static char* s_GetAppBaseName ( const char *  path)
static

Get base name of application.

Return a pointer to a newly allocated memory with zero-terminated string.

Definition at line 1189 of file ncbi_c_log.c.

References NULL, and s_StrDup().

Referenced by s_Init().

◆ s_GetClient_Env()

static const char* s_GetClient_Env ( void  )
static

This routine is called during start up and again in NcbiLog_ReqStart().

The received environment value will be cached for whole process.

Definition at line 867 of file ncbi_c_log.c.

References client, NULL, and s_StrDup().

Referenced by s_AppStart(), and s_ReqStart().

◆ s_GetContext()

static TNcbiLog_Context s_GetContext ( void  )
static

◆ s_GetPID()

static TNcbiLog_PID s_GetPID ( void  )
static

Get current process ID.

Definition at line 666 of file ncbi_c_log.c.

References sx_PID.

Referenced by s_CreateUID(), and s_PrintCommonPrefix().

◆ s_GetSubHitID()

static char* s_GetSubHitID ( TNcbiLog_Context  ctx,
int  need_increment,
const char *  prefix 
)
static

◆ s_GetTID()

static TNcbiLog_TID s_GetTID ( void  )
static

Get current thread ID.

Definition at line 682 of file ncbi_c_log.c.

Referenced by NcbiLog_UpdateOnFork(), s_CreateContext(), and s_GenerateHitID_Str_Ex().

◆ s_GetTime()

static int s_GetTime ( STime t)
static

Get current GMT time with nanoseconds (STime version)

Definition at line 795 of file ncbi_c_log.c.

References s_GetTimeT(), and t.

Referenced by NcbiLog_UpdateOnFork(), and s_PrintCommonPrefix().

◆ s_GetTimeStr()

static int s_GetTimeStr ( char *  buf,
time_t  time_sec,
unsigned long  time_ns 
)
static

Get current local time in format 'YYYY-MM-DDThh:mm:ss.sss'.

Definition at line 817 of file ncbi_c_log.c.

References buf, n, s_GetTimeT(), and t.

Referenced by s_PrintCommonPrefix().

◆ s_GetTimeT()

static int s_GetTimeT ( time_t *  time_sec,
unsigned long *  time_ns 
)
static

Update current UID with new timestamp.

This functions don't change global UID, just return a copy.

– not used at this moment, but can be usable later. Get current GMT time with nanoseconds

Definition at line 760 of file ncbi_c_log.c.

References NCBI_OS_UNIX.

Referenced by s_GenerateHitID_Str_Ex(), s_GetTime(), and s_GetTimeStr().

◆ s_GetToolkitRCLogLocation()

static const char* s_GetToolkitRCLogLocation ( )
static

Determine logs location on the base of TOOLKITRC_FILE.

Definition at line 1317 of file ncbi_c_log.c.

References SInfo_tag::app_full_name, buf, FILENAME_MAX, fp, kBaseLogDir, NULL, s_ConcatPath(), s_StrDup(), util::strncmp(), and sx_Info.

Referenced by s_InitDestination().

◆ s_Init()

static void s_Init ( const char *  appname)
static

◆ s_InitDestination()

static void s_InitDestination ( const char *  logfile_path)
static

◆ s_IsInsideRequest()

static int s_IsInsideRequest ( TNcbiLog_Context  ctx)
static

◆ s_LogHitID()

static void s_LogHitID ( TNcbiLog_Context  ctx,
const char *  hit_id 
)
static

◆ s_LogSubHitID()

static void s_LogSubHitID ( TNcbiLog_Context  ctx,
const char *  subhit_id 
)
static

Definition at line 3053 of file ncbi_c_log.c.

References assert, ctx, i, SNcbiLog_Param::key, NULL, s_AddParamsPair(), s_Extra(), and SNcbiLog_Param::value.

Referenced by s_GetSubHitID().

◆ s_MTLock_Do()

static int s_MTLock_Do ( ENcbiLog_MTLock_Action  action)
static

◆ s_OpenLogFiles()

static int s_OpenLogFiles ( void  )
static

◆ s_Post()

static void s_Post ( TNcbiLog_Context  ctx,
ENcbiLog_DiagFile  diag 
)
static

◆ s_PrintCommonPrefix()

static size_t s_PrintCommonPrefix ( TNcbiLog_Context  ctx)
static

◆ s_PrintMessage()

static void s_PrintMessage ( ENcbiLog_Severity  severity,
const char *  msg,
int  print_as_note 
)
static

◆ s_PrintParams()

static size_t s_PrintParams ( char *  dst,
size_t  pos,
const SNcbiLog_Param params 
)
static

Print parameters to message buffer.

Return new position in the buffer.

Definition at line 2321 of file ncbi_c_log.c.

References CATCH, SNcbiLog_Param::key, NCBILOG_ENTRY_MAX, s_PrintParamsPair(), SNcbiLog_Param::value, and VERIFY_CATCH.

Referenced by NcbiLog_Perf(), NcbiLog_ReqStart(), s_Extra(), and s_PrintReqStartExtraParams().

◆ s_PrintParamsPair()

static size_t s_PrintParamsPair ( char *  dst,
size_t  pos,
const char *  key,
const char *  value 
)
static

Print one parameter's pair (key, value) to message buffer.

Automatically URL encode each key and value. Return new position in the buffer.

Definition at line 2281 of file ncbi_c_log.c.

References ncbi::grid::netcache::search::fields::key, len, NCBILOG_ENTRY_MAX, s_URL_Encode(), and rapidjson::value.

Referenced by NcbiLog_Perf(), NcbiLogP_PerfStr(), and s_PrintParams().

◆ s_PrintParamsStr()

static size_t s_PrintParamsStr ( char *  dst,
size_t  pos,
const char *  params 
)
static

Print parameters to message buffer (string version).

The 'params' must be already prepared pairs with URL-encoded key and value. Return new position in the buffer.

Definition at line 2355 of file ncbi_c_log.c.

References CATCH, len, min_value, NCBILOG_ENTRY_MAX, and VERIFY_CATCH.

Referenced by NcbiLogP_PerfStr(), NcbiLogP_ReqStartStr(), and s_ExtraStr().

◆ s_PrintReqStartExtraParams()

static size_t s_PrintReqStartExtraParams ( size_t  pos)
static

Print extra parameters for request start.

Automatically URL encode each key and value. Return current position in the sx_Info->message buffer.

Definition at line 3512 of file ncbi_c_log.c.

References SInfo_tag::host_location, SInfo_tag::host_role, SNcbiLog_Param::key, SInfo_tag::message, NcbiLog_GetHostLocation(), NcbiLog_GetHostRole(), SInfo_tag::remote_logging, s_PrintParams(), sx_Info, and SNcbiLog_Param::value.

Referenced by NcbiLog_ReqStart(), and NcbiLogP_ReqStartStr().

◆ s_ReadFileString()

static const char* s_ReadFileString ( const char *  filename)
static

Read first string from specified file.

Return NULL on error.

Definition at line 604 of file ncbi_c_log.c.

References buf, fp, len, NULL, and s_StrDup().

Referenced by NcbiLog_GetHostLocation(), and NcbiLog_GetHostRole().

◆ s_ReportError()

static void s_ReportError ( long  line,
const char *  msg 
)
static

Definition at line 228 of file ncbi_c_log.c.

References SInfo_tag::destination, eNcbiLog_Stderr, and sx_Info.

◆ s_ReqStart()

static size_t s_ReqStart ( TNcbiLog_Context  ctx)
static

◆ s_SetClient()

static void s_SetClient ( char *  dst,
const char *  client 
)
static

Definition at line 1874 of file ncbi_c_log.c.

References client, len, and NCBILOG_CLIENT_MAX.

Referenced by NcbiLog_AppSetClient(), NcbiLog_SetClient(), s_AppStart(), and s_ReqStart().

◆ s_SetHitID()

static void s_SetHitID ( char *  dst,
const char *  hit_id 
)
static

◆ s_SetHost()

static void s_SetHost ( const char *  host)
static

Definition at line 1858 of file ncbi_c_log.c.

References SInfo_tag::host, len, NCBILOG_HOST_MAX, and sx_Info.

Referenced by NcbiLog_SetHost(), and s_PrintCommonPrefix().

◆ s_SetLogFiles()

static int s_SetLogFiles ( const char *  path_with_base_name,
int  is_applog 
)
static

(Re)Initialize logging file streams.

The path passed in parameter should have directory and base name for logging files.

Definition at line 1575 of file ncbi_c_log.c.

References assert, CLOSE_CLEANUP, SInfo_tag::file_err_name, SInfo_tag::file_log_name, SInfo_tag::file_perf_name, SInfo_tag::file_trace_name, FILENAME_MAX, SInfo_tag::is_applog, n, SInfo_tag::reuse_file_names, s_CloseLogFiles(), s_OpenLogFiles(), s_StrDup(), and sx_Info.

Referenced by s_InitDestination(), and s_SetLogFilesDir().

◆ s_SetLogFilesDir()

static int s_SetLogFilesDir ( const char *  dir,
int  is_applog 
)
static

(Re)Initialize logging file streams.

Use application base name and specified directory as path for logging files.

Definition at line 1610 of file ncbi_c_log.c.

References SInfo_tag::app_base_name, assert, file, FILENAME_MAX, SInfo_tag::guid, int, n, names, NULL, s_ConcatPathEx(), s_SetLogFiles(), and sx_Info.

Referenced by s_InitDestination().

◆ s_SetSession()

static void s_SetSession ( char *  dst,
const char *  session 
)
static

◆ s_SetState()

static void s_SetState ( TNcbiLog_Context  ctx,
ENcbiLog_AppState  state 
)
static

Set application state – internal version without MT locking.

We have two states: global and context-specific. We use global state if context-specific state is not specified. Setting state to eNcbiLog_App* always overwrite context-specific state. The eNcbiLog_Request* affect only context-specific state.

Definition at line 2695 of file ncbi_c_log.c.

References assert, ctx, eNcbiLog_AppBegin, eNcbiLog_AppEnd, eNcbiLog_AppRun, eNcbiLog_NotSet, eNcbiLog_Request, eNcbiLog_RequestBegin, eNcbiLog_RequestEnd, SInfo_tag::state, switch(), sx_DisableChecks, sx_Info, and TROUBLE.

Referenced by NcbiLog_AppRun(), NcbiLog_ReqRun(), NcbiLog_ReqStop(), NcbiLog_UpdateOnFork(), NcbiLogP_AppStop(), s_AppStart(), and s_ReqStart().

◆ s_SleepMicroSec()

void s_SleepMicroSec ( unsigned long  mc_sec)

Sleep the specified number of microseconds.

Portable and ugly. But we don't need more precision version here, we will use it only for context switches and avoiding possible CPU load.

Definition at line 494 of file ncbi_c_log.c.

References int.

◆ s_StrDup()

static char* s_StrDup ( const char *  str)
static

◆ s_TlsDestroy()

static void s_TlsDestroy ( void  )
static

Definition at line 411 of file ncbi_c_log.c.

References assert, sx_Tls, sx_TlsIsInit, TROUBLE, and verify.

Referenced by NcbiLog_Destroy().

◆ s_TlsGetValue()

static void* s_TlsGetValue ( void  )
static

Definition at line 425 of file ncbi_c_log.c.

References assert, NULL, sx_Tls, sx_TlsIsInit, and TROUBLE.

Referenced by s_AttachContext(), s_DestroyContext(), and s_GetContext().

◆ s_TlsInit()

static void s_TlsInit ( void  )
static

Definition at line 391 of file ncbi_c_log.c.

References assert, NULL, sx_Tls, sx_TlsIsInit, and verify.

Referenced by s_Init().

◆ s_TlsSetValue()

static void s_TlsSetValue ( void *  ptr)
static

Definition at line 443 of file ncbi_c_log.c.

References assert, sx_Tls, sx_TlsIsInit, TROUBLE, and verify.

Referenced by NcbiLog_Context_Detach(), s_AttachContext(), and s_DestroyContext().

◆ s_URL_Encode()

static void s_URL_Encode ( const void *  src_buf,
size_t  src_size,
size_t *  src_read,
void *  dst_buf,
size_t  dst_size,
size_t *  dst_written 
)
static

URL-encode up to "src_size" symbols(bytes) from buffer "src_buf".

Write the encoded data to buffer "dst_buf", but no more than "dst_size" bytes. Assign "*src_read" to the # of bytes successfully encoded from "src_buf". Assign "*dst_written" to the # of bytes written to buffer "dst_buf".

Definition at line 1014 of file ncbi_c_log.c.

References sx_EncodeTable.

Referenced by s_Init(), s_PrintParamsPair(), s_SetHitID(), and s_SetSession().

◆ s_Write()

static size_t s_Write ( int  fd,
const void *  buf,
size_t  count 
)
static

Definition at line 2057 of file ncbi_c_log.c.

References buf, and n.

Referenced by NcbiLogP_Raw2(), and s_Post().

Variable Documentation

◆ kBaseLogDir

const char* kBaseLogDir = "/log/"
static

Definition at line 166 of file ncbi_c_log.c.

Referenced by s_GetToolkitRCLogLocation(), and s_InitDestination().

◆ sx_AppStateStr

const char* sx_AppStateStr[]
static
Initial value:
= {
"NS", "PB", "P", "PE", "RB", "R", "RE"
}

Definition at line 2162 of file ncbi_c_log.c.

Referenced by s_PrintCommonPrefix().

◆ sx_ContextST

volatile TNcbiLog_Context sx_ContextST = NULL
static

◆ sx_DisableChecks

volatile int sx_DisableChecks = 0
static

Definition at line 181 of file ncbi_c_log.c.

Referenced by NcbiLogP_DisableChecks(), and s_SetState().

◆ sx_EncodeTable

const unsigned char sx_EncodeTable[256][4]
static

Definition at line 973 of file ncbi_c_log.c.

Referenced by s_URL_Encode().

◆ sx_Info

volatile TNcbiLog_Info* sx_Info = NULL
static

◆ sx_IsEnabled

volatile int sx_IsEnabled = 0
static

Definition at line 178 of file ncbi_c_log.c.

Referenced by NcbiLog_Destroy(), and s_Init().

◆ sx_IsInit

volatile int sx_IsInit = 0
static

◆ sx_MT_handle

pthread_mutex_t sx_MT_handle = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 250 of file ncbi_c_log.c.

◆ sx_MTLock

volatile TNcbiLog_MTLock sx_MTLock = &sx_MTLock_Default
static

Definition at line 318 of file ncbi_c_log.c.

Referenced by NcbiLog_Destroy(), NcbiLog_Init(), s_Init(), and s_MTLock_Do().

◆ sx_MTLock_Default

struct TNcbiLog_MTLock_tag sx_MTLock_Default = {NULL, NcbiLog_Default_MTLock_Handler, 0x4C0E681F }
static

Definition at line 255 of file ncbi_c_log.c.

◆ sx_MTLock_Own

volatile int sx_MTLock_Own = 0
static

Definition at line 323 of file ncbi_c_log.c.

Referenced by NcbiLog_Destroy(), and NcbiLog_Init().

◆ sx_PID

volatile TNcbiLog_PID sx_PID = 0
static

Definition at line 190 of file ncbi_c_log.c.

Referenced by NcbiLog_UpdateOnFork(), and s_GetPID().

◆ sx_SeverityStr

const char* sx_SeverityStr[]
static
Initial value:
= {
"Trace", "Info", "Warning", "Error", "Critical", "Fatal"
}

Definition at line 2375 of file ncbi_c_log.c.

Referenced by s_PrintMessage().

◆ sx_Tls

volatile pthread_key_t sx_Tls
static

Definition at line 385 of file ncbi_c_log.c.

Referenced by s_TlsDestroy(), s_TlsGetValue(), s_TlsInit(), and s_TlsSetValue().

◆ sx_TlsIsInit

volatile int sx_TlsIsInit = 0
static
Modified on Tue Jul 16 13:23:24 2024 by modify_doxy.py rev. 669887