Macros | Functions | Variables
log.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <uv.h>
#include "auto/config.h"
#include "nvim/log.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/types.h"

Macros

#define LOG_FILE_ENV   "NVIM_LOG_FILE"
 

Functions

void log_init (void)
 
void log_lock (void)
 
void log_unlock (void)
 
bool logmsg (int log_level, const char *context, const char *func_name, int line_num, bool eol, const char *fmt,...) FUNC_ATTR_UNUSED FUNC_ATTR_PRINTF(6
 
 if (log_file==NULL)
 
 va_start (args, fmt)
 
 va_end (args)
 
 if (log_file !=stderr &&log_file !=stdout)
 
void log_uv_handles (void *loop)
 
FILE * open_log_file (void)
 
static bool assert (log_level >=DEBUG_LOG_LEVEL &&log_level<=ERROR_LOG_LEVEL)
 
 if (os_localtime(&local_time)==NULL)
 
 if (strftime(date_time, sizeof(date_time), "%Y-%m-%dT%H:%M:%S", &local_time)==0)
 
 if (uv_gettimeofday(&curtime)==0)
 
 if (rv< 0)
 
 if (eol)
 
 if (fflush(log_file)==EOF)
 

Variables

bool bool ret = false
 
FILE * log_file = open_log_file()
 
va_list args
 
end __pad0__
 
struct tm local_time
 
char date_time [20]
 
int millis = 0
 
uv_timeval64_t curtime
 
int64_t pid = os_get_pid()
 
int rv
 
return true
 

Macro Definition Documentation

◆ LOG_FILE_ENV

#define LOG_FILE_ENV   "NVIM_LOG_FILE"

Function Documentation

◆ assert()

static bool assert ( log_level >=DEBUG_LOG_LEVEL &&log_level<=  ERROR_LOG_LEVEL)

◆ if() [1/8]

if ( eol  )

◆ if() [2/8]

if ( fflush(log_file = = EOF)

◆ if() [3/8]

if ( log_file = stderr && log_file != stdout)

◆ if() [4/8]

if ( log_file  = NULL)

◆ if() [5/8]

if ( os_localtime local_time = NULL)

◆ if() [6/8]

if ( )

◆ if() [7/8]

if ( strftime(date_time, sizeof(date_time), "%Y-%m-%dT%H:%M:%S", &local_time)  = = 0)

◆ if() [8/8]

if ( uv_gettimeofday &  curtime = = 0)

◆ log_init()

void log_init ( void  )

◆ log_lock()

void log_lock ( void  )

◆ log_unlock()

void log_unlock ( void  )

◆ log_uv_handles()

void log_uv_handles ( void loop)

◆ logmsg()

bool logmsg ( int  log_level,
const char *  context,
const char *  func_name,
int  line_num,
bool  eol,
const char *  fmt,
  ... 
)

Logs a message to $NVIM_LOG_FILE.

Parameters
log_levelLog level (see log.h)
contextDescription of a shared context or subsystem
func_nameFunction name, or NULL
line_numSource line number, or -1
eolAppend linefeed "\n"
fmtprintf-style format string

◆ open_log_file()

FILE* open_log_file ( void  )

Open the log file for appending.

Returns
FILE* decided by log_path_init() or stderr in case of error

◆ va_end()

va_end ( args  )

◆ va_start()

static bool va_start ( args  ,
fmt   
)
Initial value:
{
va_list args

Variable Documentation

◆ __pad0__

end __pad0__

◆ args

va_list args

◆ curtime

uv_timeval64_t curtime

◆ date_time

char date_time[20]

◆ local_time

struct tm local_time

◆ log_file

FILE* log_file = open_log_file()

◆ millis

int millis = 0

◆ pid

int64_t pid = os_get_pid()

◆ ret

return ret = false

◆ rv

int rv
Initial value:
= (line_num == -1 || func_name == NULL)
? fprintf(log_file, "%s %s.%03d %-5" PRId64 " %s",
log_levels[log_level], date_time, millis, pid,
(context == NULL ? "?:" : context))
: fprintf(log_file, "%s %s.%03d %-5" PRId64 " %s%s:%d: ",
log_levels[log_level], date_time, millis, pid,
(context == NULL ? "" : context),
func_name, line_num)

◆ true

return true
pid
int64_t pid
Definition: log.c:313
millis
int millis
Definition: log.c:306
date_time
char date_time[20]
Definition: log.c:300
log_file
FILE * log_file
Definition: log.c:143
args
va_list args
Definition: log.c:149
NULL
return NULL
Definition: eval.c:9968