Blame src/log/toks_log_service_info.c

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