const _checkStrValue = (value) => 
{
	return value !== undefined && value !== null ? value.toString() : "";
}

const traceLog = (value) => 
{
	if(typeof window === 'undefined')
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_SERVER, 10) === 1)
		{
			console.log(value);
		}
	}
	else
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_CLIENT, 10) === 1)
		{
			console.log(value);
		}
		else
		{
			if(global.store?.getState()?.auth?.observer)
			{
				console.log(value);
			}
		}
	}
}

const traceDebug = (value) => 
{
	if(typeof window === 'undefined')
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_SERVER, 10) === 1)
		{
			console.debug(value);
		}
	}
	else
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_CLIENT, 10) === 1)
		{
			console.debug(value);
		}
		else
		{
			if(global.store?.getState()?.auth?.observer)
			{
				console.debug(value);
			}
		}
	}
}

const traceError = (value) => 
{
	if(typeof window === 'undefined')
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_SERVER, 10) === 1)
		{
			console.error(value);
		}
	}
	else
	{
		if(parseInt(process.env.NEXT_PUBLIC_CONSOLE_LOG_CLIENT, 10) === 1)
		{
			console.error(value);
		}
		else
		{
			if(global.store?.getState()?.auth?.observer)
			{
				console.error(value);
			}
		}
	}
}

export { _checkStrValue, traceLog, traceDebug, traceError }