NCBI C++ ToolKit
|
#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>
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_Info * | NcbiLogP_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_Info * | sx_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 [] |
#define CATCH __catch_error |
Definition at line 131 of file ncbi_c_log.c.
#define CHECK_APP_START | ( | ctx | ) |
Definition at line 474 of file ncbi_c_log.c.
#define DIR_SEPARATOR '\\' |
Definition at line 144 of file ncbi_c_log.c.
#define kIdBufSize 128 |
#define kMTLock_magic_number 0x4C0E681F |
Definition at line 312 of file ncbi_c_log.c.
Definition at line 140 of file ncbi_c_log.c.
#define MT_DESTROY verify(MT_LOCK_Do(eNcbiLog_MT_Destroy) != 0) |
Definition at line 344 of file ncbi_c_log.c.
#define MT_INIT verify(MT_LOCK_Do(eNcbiLog_MT_Init) != 0) |
Definition at line 341 of file ncbi_c_log.c.
#define MT_LOCK verify(MT_LOCK_Do(eNcbiLog_MT_Lock) != 0) |
Definition at line 342 of file ncbi_c_log.c.
#define MT_LOCK_API |
Definition at line 462 of file ncbi_c_log.c.
#define MT_LOCK_Do | ( | action | ) | (sx_MTLock ? s_MTLock_Do((action)) : -1) |
Definition at line 337 of file ncbi_c_log.c.
#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.
#define MT_UNLOCK verify(MT_LOCK_Do(eNcbiLog_MT_Unlock) != 0) |
Definition at line 343 of file ncbi_c_log.c.
#define NCBI_WIN32_THREADS |
Definition at line 62 of file ncbi_c_log.c.
#define TROUBLE s_Abort(__LINE__, 0) |
Definition at line 87 of file ncbi_c_log.c.
#define TROUBLE_MSG | ( | msg | ) | s_Abort(__LINE__, msg) |
Definition at line 88 of file ncbi_c_log.c.
#define UNKNOWN_APPNAME "UNK_APP" |
Definition at line 159 of file ncbi_c_log.c.
#define UNKNOWN_CLIENT "UNK_CLIENT" |
Definition at line 156 of file ncbi_c_log.c.
#define UNKNOWN_HITID "" |
Definition at line 158 of file ncbi_c_log.c.
#define UNKNOWN_HOST "UNK_HOST" |
Definition at line 155 of file ncbi_c_log.c.
#define UNKNOWN_SESSION "UNK_SESSION" |
Definition at line 157 of file ncbi_c_log.c.
#define UNUSED_ARG | ( | x | ) | x##_UNUSED |
Definition at line 136 of file ncbi_c_log.c.
#define verify | ( | expr | ) | assert(expr) |
Definition at line 97 of file ncbi_c_log.c.
#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.
#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.
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.
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().
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().
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 '&'.
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().
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().
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().
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().
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().
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().
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().
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().
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().
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 '&'.
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().
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().
void NcbiLogP_Raw2 | ( | const char * | line, |
size_t | n | ||
) |
Variant of NcbiLogP_Raw with already known line size to avoid double length calculation.
line[n] still should be '\0'.
Definition at line 3868 of file ncbi_c_log.c.
References SInfo_tag::appname, CATCH, SInfo_tag::destination, eNcbiLog_Cwd, eNcbiLog_Default, eNcbiLog_Disable, eNcbiLog_File, eNcbiLog_Stderr, eNcbiLog_Stdlog, eNcbiLog_Stdout, f(), SInfo_tag::file_err, SInfo_tag::file_log, SInfo_tag::file_perf, SInfo_tag::file_trace, kInvalidFileHandle, len, SInfo_tag::message, MT_LOCK_API, MT_UNLOCK, n, NCBILOG_APPNAME_MAX, NCBILOG_ENTRY_MAX, NCBILOG_ENTRY_MIN, NULL, s_InitDestination(), s_Write(), util::strncmp(), sx_Info, VERIFY, and VERIFY_CATCH.
Referenced by NcbiLogP_Raw(), and CNcbiApplogApp::Run().
void NcbiLogP_ReInit | ( | void | ) |
Definition at line 2638 of file ncbi_c_log.c.
References sx_IsInit.
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 '&'.
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().
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
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().
Definition at line 197 of file ncbi_c_log.c.
References abort(), and exit().
Referenced by s_PrintMessage().
|
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().
|
static |
Print "start" message.
We should print "start" message always, before any other message. The NcbiLog_AppStart() is just a wrapper for this with checks and MT locking.
Definition at line 3302 of file ncbi_c_log.c.
References SInfo_tag::app_start_time, buf, CATCH, SInfo_tag::client, ctx, eDiag_Log, eNcbiLog_AppBegin, i, SInfo_tag::message, NCBILOG_HITID_MAX, NcbiLogP_GetHitID_Env(), NcbiLogP_GetSessionID_Env(), STime_tag::ns, NULL, SInfo_tag::phid, SInfo_tag::phid_inherit, SInfo_tag::post_time, s_GenerateHitID_Str(), s_GetClient_Env(), s_Post(), s_PrintCommonPrefix(), s_SetClient(), s_SetHitID(), s_SetSession(), s_SetState(), STime_tag::sec, SInfo_tag::session, sx_Info, and VERIFY_CATCH.
Referenced by NcbiLog_AppStart(), and NcbiLog_UpdateOnFork().
|
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().
Close log files for a current destination.
Files can be fully cleaned for setting a new destination or just closed to be reopened later with the same destination.
Definition at line 1414 of file ncbi_c_log.c.
References cleanup(), close(), SInfo_tag::destination, eNcbiLog_Cwd, eNcbiLog_Default, eNcbiLog_Disable, eNcbiLog_File, eNcbiLog_Stderr, eNcbiLog_Stdlog, eNcbiLog_Stdout, SInfo_tag::file_err, SInfo_tag::file_err_name, SInfo_tag::file_log, SInfo_tag::file_log_name, SInfo_tag::file_perf, SInfo_tag::file_perf_name, SInfo_tag::file_trace, SInfo_tag::file_trace_name, free(), kInvalidFileHandle, NULL, SInfo_tag::reuse_file_names, sx_Info, and TROUBLE_MSG.
Referenced by NcbiLog_Destroy(), NcbiLog_SetDestination(), NcbiLog_SetDestinationFile(), s_InitDestination(), and s_SetLogFiles().
|
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().
|
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().
|
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().
|
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().
|
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().
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().
|
static |
Escape newlines in the string.
Follow CXX-7439 applog standard newline replacement convention.
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().
|
static |
Definition at line 3674 of file ncbi_c_log.c.
References buf, CATCH, ctx, eDiag_Log, SInfo_tag::message, s_Post(), s_PrintCommonPrefix(), s_PrintParams(), sx_Info, and VERIFY_CATCH.
Referenced by NcbiLog_AppRun(), NcbiLog_Extra(), s_LogHitID(), and s_LogSubHitID().
|
static |
Definition at line 3695 of file ncbi_c_log.c.
References buf, CATCH, ctx, eDiag_Log, SInfo_tag::message, s_Post(), s_PrintCommonPrefix(), s_PrintParamsStr(), sx_Info, and VERIFY_CATCH.
Referenced by NcbiLog_UpdateOnFork(), and NcbiLogP_ExtraStr().
|
static |
Definition at line 2007 of file ncbi_c_log.c.
References s_GenerateHitID_Str_Ex().
Referenced by NcbiLog_ReqRun(), and s_AppStart().
|
static |
Definition at line 1969 of file ncbi_c_log.c.
References SInfo_tag::guid, int, n, NULL, SInfo_tag::rid, s_CreateUID(), s_GetTID(), s_GetTimeT(), and sx_Info.
Referenced by NcbiLogP_GenerateHitID(), and s_GenerateHitID_Str().
|
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().
|
static |
Definition at line 1938 of file ncbi_c_log.c.
References SInfo_tag::guid, int, n, NCBILOG_UINT8_FORMAT_SPEC, NULL, SInfo_tag::rid, s_CreateUID(), and sx_Info.
Referenced by NcbiLogP_GenerateSID(), and s_GenerateSID_Str().
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().
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().
|
static |
Get pointer to the thread-specific context.
Definition at line 1277 of file ncbi_c_log.c.
References assert, ctx, NULL, s_AttachContext(), s_CreateContext(), s_TlsGetValue(), sx_ContextST, sx_IsInit, sx_TlsIsInit, and VERIFY.
Referenced by NcbiLog_AppRun(), NcbiLog_AppStart(), NcbiLog_Extra(), NcbiLog_GetCurrentSubHitID_Prefix(), NcbiLog_GetHitID(), NcbiLog_GetNextSubHitID_Prefix(), NcbiLog_GetSession(), NcbiLog_GetState(), NcbiLog_NewSession(), NcbiLog_Perf(), NcbiLog_ReqRun(), NcbiLog_ReqStart(), NcbiLog_ReqStop(), NcbiLog_SetClient(), NcbiLog_SetHitID(), NcbiLog_SetSession(), NcbiLog_SetThreadId(), NcbiLog_UpdateOnFork(), NcbiLogP_AppStop(), NcbiLogP_ExtraStr(), NcbiLogP_GetContextPtr(), NcbiLogP_PerfStr(), NcbiLogP_ReqStartStr(), and s_PrintMessage().
|
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().
|
static |
Definition at line 3156 of file ncbi_c_log.c.
References buf, CATCH, ctx, n, NCBILOG_HITID_MAX, NULL, SInfo_tag::phid, SInfo_tag::phid_inherit, SInfo_tag::phid_sub_id, prefix, s_IsInsideRequest(), s_LogSubHitID(), s_StrDup(), sx_Info, and VERIFY_CATCH.
Referenced by NcbiLog_GetCurrentSubHitID_Prefix(), and NcbiLog_GetNextSubHitID_Prefix().
|
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().
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().
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().
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().
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().
Definition at line 2445 of file ncbi_c_log.c.
References SInfo_tag::app_base_name, SInfo_tag::app_full_name, SInfo_tag::appname, assert, SInfo_tag::destination, eNcbiLog_Default, eNcbiLog_Error, eNcbiLog_Warning, SInfo_tag::file_err, SInfo_tag::file_log, SInfo_tag::file_perf, SInfo_tag::file_trace, kInvalidFileHandle, len, malloc(), SInfo_tag::message, NCBILOG_APPNAME_MAX, NCBILOG_ENTRY_MAX_ALLOC, NcbiLogP_GetEnv_UInt(), NULL, SInfo_tag::phid_sub_id_limit, SInfo_tag::post_level, SInfo_tag::psn, s_GetAppBaseName(), s_StrDup(), s_TlsInit(), s_URL_Encode(), sx_Info, sx_IsEnabled, sx_MTLock, sx_TlsIsInit, and verify.
Referenced by NcbiLog_Init(), and NcbiLog_InitForAttachedContext().
(Re)Initialize destination.
Definition at line 1684 of file ncbi_c_log.c.
References assert, CLOSE_CLEANUP, CLOSE_FOR_REOPEN, SInfo_tag::destination, eNcbiLog_Cwd, eNcbiLog_Default, eNcbiLog_Disable, eNcbiLog_File, eNcbiLog_Stderr, eNcbiLog_Stdlog, eNcbiLog_Stdout, SInfo_tag::file_err, SInfo_tag::file_log, SInfo_tag::file_perf, SInfo_tag::file_trace, FILENAME_MAX, free(), kBaseLogDir, kInvalidFileHandle, SInfo_tag::last_reopen_time, SInfo_tag::logsite, NO_LOG, NULL, SInfo_tag::reuse_file_names, s_CloseLogFiles(), s_ConcatPath(), s_GetToolkitRCLogLocation(), s_OpenLogFiles(), s_SetLogFiles(), s_SetLogFilesDir(), SInfo_tag::server_port, STDOUT_FILENO, sx_Info, TO_LOG, and TROUBLE.
Referenced by NcbiLog_SetDestination(), NcbiLog_SetDestinationFile(), NcbiLogP_Raw2(), NcbiLogP_SetDestination(), and s_Post().
|
static |
Definition at line 1921 of file ncbi_c_log.c.
References ctx, eNcbiLog_NotSet, eNcbiLog_Request, eNcbiLog_RequestBegin, SInfo_tag::state, switch(), and sx_Info.
Referenced by NcbiLog_GetHitID(), NcbiLog_GetSession(), NcbiLog_Perf(), NcbiLog_SetHitID(), NcbiLogP_PerfStr(), and s_GetSubHitID().
|
static |
Definition at line 3043 of file ncbi_c_log.c.
References assert, ctx, i, SNcbiLog_Param::key, NULL, s_AddParamsPair(), s_Extra(), and SNcbiLog_Param::value.
Referenced by NcbiLog_ReqRun(), NcbiLog_SetHitID(), and NcbiLog_UpdateOnFork().
|
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().
|
static |
Definition at line 330 of file ncbi_c_log.c.
References TNcbiLog_MTLock_tag::handler, MT_LOCK_VALID, sx_MTLock, and TNcbiLog_MTLock_tag::user_data.
Open file streams.
All file names should be already defined.
Definition at line 1500 of file ncbi_c_log.c.
References assert, SInfo_tag::file_err, SInfo_tag::file_err_name, SInfo_tag::file_log, SInfo_tag::file_log_name, SInfo_tag::file_perf, SInfo_tag::file_perf_name, SInfo_tag::file_trace, SInfo_tag::file_trace_name, flags, SInfo_tag::is_applog, kInvalidFileHandle, SInfo_tag::split_log_file, and sx_Info.
Referenced by s_InitDestination(), and s_SetLogFiles().
|
static |
Post prepared message into the log.
The severity parameter is necessary to choose correct logging file.
Definition at line 2090 of file ncbi_c_log.c.
References assert, CATCH, ctx, SInfo_tag::destination, eDiag_Err, eDiag_Log, eDiag_Perf, eDiag_Trace, eNcbiLog_Disable, f(), SInfo_tag::file_err, SInfo_tag::file_log, SInfo_tag::file_perf, SInfo_tag::file_trace, kInvalidFileHandle, SInfo_tag::message, n, NCBILOG_ENTRY_MAX, STime_tag::ns, NULL, SInfo_tag::post_time, SInfo_tag::psn, s_InitDestination(), s_Write(), STime_tag::sec, sx_Info, TROUBLE, SInfo_tag::user_posting_time, VERIFY, and VERIFY_CATCH.
Referenced by NcbiLog_Perf(), NcbiLog_ReqStart(), NcbiLog_ReqStop(), NcbiLogP_AppStop(), NcbiLogP_PerfStr(), NcbiLogP_ReqStartStr(), s_AppStart(), s_Extra(), s_ExtraStr(), and s_PrintMessage().
|
static |
Print common prefix to message buffer.
Return number of written bytes (current position in message buffer), or zero on error. See documentation about log format: https://ncbi.github.io/cxx-toolkit/pages/ch_log#ch_core.The_New_Post_Format C++ implementation: CDiagContext::WriteStdPrefix() (src/corelib/ncbidiag.cpp)
Definition at line 2172 of file ncbi_c_log.c.
References SInfo_tag::appname, SInfo_tag::client, ctx, eNcbiLog_NotSet, eNcbiLog_Request, eNcbiLog_RequestBegin, eNcbiLog_RequestEnd, SInfo_tag::guid, SInfo_tag::host, int, SInfo_tag::message, n, NcbiLog_GetHostName(), NCBILOG_UINT8_FORMAT_SPEC, STime_tag::ns, SInfo_tag::pid, SInfo_tag::post_time, SInfo_tag::psn, s_CreateUID(), s_GetPID(), s_GetTime(), s_GetTimeStr(), s_SetHost(), STime_tag::sec, SInfo_tag::session, SInfo_tag::state, switch(), sx_AppStateStr, sx_Info, UNKNOWN_APPNAME, UNKNOWN_CLIENT, UNKNOWN_HOST, and UNKNOWN_SESSION.
Referenced by NcbiLog_Perf(), NcbiLog_ReqStop(), NcbiLogP_AppStop(), NcbiLogP_PerfStr(), s_AppStart(), s_Extra(), s_ExtraStr(), s_PrintMessage(), and s_ReqStart().
|
static |
Print a message with severity to message buffer.
Definition at line 2381 of file ncbi_c_log.c.
References buf, CATCH, CHECK_APP_START, ctx, eDiag_Err, eDiag_Trace, eNcbiLog_Critical, eNcbiLog_Error, eNcbiLog_Fatal, eNcbiLog_Info, eNcbiLog_Trace, eNcbiLog_Warning, SInfo_tag::message, MT_LOCK_API, MT_UNLOCK, NCBILOG_ENTRY_MAX, s_Abort(), s_EscapeNewlines(), s_GetContext(), s_Post(), s_PrintCommonPrefix(), sx_Info, sx_SeverityStr, TROUBLE, and VERIFY_CATCH.
Referenced by NcbiLog_Critical(), NcbiLog_Error(), NcbiLog_Fatal(), NcbiLog_Info(), NcbiLog_Note(), NcbiLog_Trace(), and NcbiLog_Warning().
|
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().
|
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().
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().
|
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().
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().
Definition at line 228 of file ncbi_c_log.c.
References SInfo_tag::destination, eNcbiLog_Stderr, and sx_Info.
|
static |
Definition at line 3446 of file ncbi_c_log.c.
References CATCH, CHECK_APP_START, ctx, eNcbiLog_RequestBegin, ip, SInfo_tag::message, n, NCBILOG_SESSION_MAX, NcbiLogP_GetSessionID_Env(), STime_tag::ns, SInfo_tag::post_time, SInfo_tag::rid, s_GenerateSID_Str(), s_GetClient_Env(), s_PrintCommonPrefix(), s_SetClient(), s_SetSession(), s_SetState(), STime_tag::sec, sx_Info, and VERIFY_CATCH.
Referenced by NcbiLog_ReqStart(), and NcbiLogP_ReqStartStr().
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().
Definition at line 1905 of file ncbi_c_log.c.
References len, NCBILOG_HITID_MAX, s_URL_Encode(), and verify.
Referenced by NcbiLog_AppSetHitID(), NcbiLog_ReqRun(), NcbiLog_SetHitID(), and s_AppStart().
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().
(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().
(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().
Definition at line 1890 of file ncbi_c_log.c.
References len, NCBILOG_SESSION_MAX, s_URL_Encode(), and verify.
Referenced by NcbiLog_AppNewSession(), NcbiLog_AppSetSession(), NcbiLog_NewSession(), NcbiLog_SetSession(), s_AppStart(), and s_ReqStart().
|
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().
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.
strdup() doesn't exists on all platforms, and we cannot check this here.
Will use our own implementation.
Definition at line 516 of file ncbi_c_log.c.
References malloc(), ncbi::grid::netcache::search::fields::size, and str().
Referenced by NcbiLog_AppGetHitID(), NcbiLog_AppGetSession(), NcbiLog_GetHitID(), NcbiLog_GetHostLocation(), NcbiLog_GetHostName(), NcbiLog_GetHostRole(), NcbiLog_GetSession(), NcbiLogP_GetHitID_Env(), NcbiLogP_GetSessionID_Env(), s_GetAppBaseName(), s_GetClient_Env(), s_GetSubHitID(), s_GetToolkitRCLogLocation(), s_Init(), s_ReadFileString(), and s_SetLogFiles().
|
static |
Definition at line 411 of file ncbi_c_log.c.
References assert, sx_Tls, sx_TlsIsInit, TROUBLE, and verify.
Referenced by NcbiLog_Destroy().
|
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().
|
static |
Definition at line 391 of file ncbi_c_log.c.
References assert, NULL, sx_Tls, sx_TlsIsInit, and verify.
Referenced by s_Init().
|
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().
|
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().
Definition at line 2057 of file ncbi_c_log.c.
Referenced by NcbiLogP_Raw2(), and s_Post().
|
static |
Definition at line 166 of file ncbi_c_log.c.
Referenced by s_GetToolkitRCLogLocation(), and s_InitDestination().
|
static |
Definition at line 2162 of file ncbi_c_log.c.
Referenced by s_PrintCommonPrefix().
|
static |
Definition at line 187 of file ncbi_c_log.c.
Referenced by NcbiLog_Context_Detach(), s_AttachContext(), s_DestroyContext(), and s_GetContext().
|
static |
Definition at line 181 of file ncbi_c_log.c.
Referenced by NcbiLogP_DisableChecks(), and s_SetState().
|
static |
Definition at line 973 of file ncbi_c_log.c.
Referenced by s_URL_Encode().
|
static |
Definition at line 184 of file ncbi_c_log.c.
Referenced by NcbiLog_AppGetHitID(), NcbiLog_AppGetSession(), NcbiLog_AppNewSession(), NcbiLog_AppRun(), NcbiLog_AppSetClient(), NcbiLog_AppSetHitID(), NcbiLog_AppSetSession(), NcbiLog_Destroy(), NcbiLog_GetCurrentSubHitID_Prefix(), NcbiLog_GetHitID(), NcbiLog_GetNextSubHitID_Prefix(), NcbiLog_GetRequestId(), NcbiLog_GetSession(), NcbiLog_GetState(), NcbiLog_Perf(), NcbiLog_ReqRun(), NcbiLog_ReqStart(), NcbiLog_ReqStop(), NcbiLog_SetDestination(), NcbiLog_SetDestinationFile(), NcbiLog_SetPostLevel(), NcbiLog_SetProcessId(), NcbiLog_SetRequestId(), NcbiLog_SetSplitLogFile(), NcbiLog_SetTime(), NcbiLog_UpdateOnFork(), NcbiLogP_AppStop(), NcbiLogP_GetInfoPtr(), NcbiLogP_PerfStr(), NcbiLogP_Raw2(), NcbiLogP_ReqStartStr(), NcbiLogP_SetDestination(), s_AppStart(), s_CloseLogFiles(), s_Extra(), s_ExtraStr(), s_GenerateHitID_Str_Ex(), s_GenerateSID_Str_Ex(), s_GetSubHitID(), s_GetToolkitRCLogLocation(), s_Init(), s_InitDestination(), s_IsInsideRequest(), s_OpenLogFiles(), s_Post(), s_PrintCommonPrefix(), s_PrintMessage(), s_PrintReqStartExtraParams(), s_ReportError(), s_ReqStart(), s_SetHost(), s_SetLogFiles(), s_SetLogFilesDir(), and s_SetState().
|
static |
Definition at line 178 of file ncbi_c_log.c.
Referenced by NcbiLog_Destroy(), and s_Init().
|
static |
Definition at line 175 of file ncbi_c_log.c.
Referenced by NcbiLog_Destroy(), NcbiLog_GetState(), NcbiLog_Init(), NcbiLog_InitForAttachedContext(), NcbiLogP_ReInit(), and s_GetContext().
|
static |
Definition at line 250 of file ncbi_c_log.c.
|
static |
Definition at line 318 of file ncbi_c_log.c.
Referenced by NcbiLog_Destroy(), NcbiLog_Init(), s_Init(), and s_MTLock_Do().
|
static |
Definition at line 255 of file ncbi_c_log.c.
|
static |
Definition at line 323 of file ncbi_c_log.c.
Referenced by NcbiLog_Destroy(), and NcbiLog_Init().
|
static |
Definition at line 190 of file ncbi_c_log.c.
Referenced by NcbiLog_UpdateOnFork(), and s_GetPID().
|
static |
Definition at line 2375 of file ncbi_c_log.c.
Referenced by s_PrintMessage().
|
static |
Definition at line 385 of file ncbi_c_log.c.
Referenced by s_TlsDestroy(), s_TlsGetValue(), s_TlsInit(), and s_TlsSetValue().
|
static |
Definition at line 381 of file ncbi_c_log.c.
Referenced by NcbiLog_Context_Detach(), NcbiLog_Destroy(), s_AttachContext(), s_DestroyContext(), s_GetContext(), s_Init(), s_TlsDestroy(), s_TlsGetValue(), s_TlsInit(), and s_TlsSetValue().