/*********************************************************/
/* toksvc: a framework-native token broker service */
/* Copyright (C) 2020 Z. Gilboa */
/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */
/*********************************************************/
#include <psxtypes/psxtypes.h>
#include <ntapi/nt_tty.h>
#include <toksvc/toksvc.h>
#include "toksvc_driver_impl.h"
#include "toksvc_daemon_impl.h"
#include "toksvc_log_impl.h"
void toks_log_service_info(struct toks_daemon_ctx * dctx)
{
struct toks_driver_ctx * drvctx = dctx->driver_ctx;
TOKS_LOG_LEVEL(drvctx,1);
nt_cid cid;
void * addr;
char * mark;
char path[2048];
char uuid[40];
char sbuf[64];
cid.process_id = pe_get_current_process_id();
cid.thread_id = pe_get_current_thread_id();
sbuf[0] = 0;
toks_log_get_arbitrary_process_name(
&cid,path,sizeof(path));
toks_uuid_to_string(drvctx->cctx->uuid,&uuid);
if (dctx->request.syncinfo.ipcsvc.keys.key[0]) {
addr = dctx->request.syncinfo.ipcsvc.keys.key;
mark = addr;
ntapi->sprintf(sbuf,".refstr=``%s'', ",mark);
}
toks_log_header(
drvctx,
TOKS_LOG_ENTRY_SERVER_INFO,
"token service information for %s "
"(syspid %d, systid %d): "
"DRIVER_INFO = {"
".uuid=%s, "
".allocated_tokens=%d, "
".available_tokens=%d, "
".log_level=%d}, "
"%s"
"DAEMON_INFO = {"
".free_tokens=%d, "
".used_tokens=%d, "
".controlling_pid=%d, "
".controlling_syspid=%d}\n",
toks_log_basename(path),
cid.process_id,
cid.thread_id,
uuid,
toks_get_driver_atokens(dctx->driver_ctx),
toks_get_driver_ntokens(dctx->driver_ctx),
dctx->driver_ctx->cctx->loglevel,
sbuf,
dctx->ftokens,
dctx->utokens,
dctx->ctrlpid,
dctx->csyspid);
toks_log_write(
drvctx,
TOKS_LOG_ENTRY_SUB_LEVEL_2,
"%s.\n",path);
}