Instead of working with strings, concatenation, placing commas in quotes, etc., you could do this:
function Logs{
param(
$type,
$status
)
[PSCustomObject]@{
date = Get-Date -Format "MM:dd:yyyy"
log_type = $type
status = $status
} | Export-CSV logging.csv -NoTypeInformation -Append
if ($type -eq "error") {
Write-Host ""
}...
}
Just to make a point, your function contains an error: "date=$date" + " , " + "log_type=$type" , " + "status=$status" -- it's missing a concatenation operation and a double-quote.
You can accomplish the same thing like this: "date={0} , log_type={1} , status={2} -f $date, $type, $status" | Out-File logging.csv -Append -- without all the quoting and concatenation.