Consolidate StringBuilder method calls. Remove commented code.
This commit is contained in:
parent
6804e1af58
commit
db1503fc3b
1 changed files with 23 additions and 37 deletions
|
@ -25,46 +25,32 @@ Get-Content -Tail $lines -Wait -Path $inFile | ForEach-Object {
|
||||||
$userAgent = $r.headers.'User-Agent' | Select-Object -First 1
|
$userAgent = $r.headers.'User-Agent' | Select-Object -First 1
|
||||||
$referer = $r.headers.Referer | Select-Object -First 1
|
$referer = $r.headers.Referer | Select-Object -First 1
|
||||||
|
|
||||||
$null = $builder.Clear()
|
$commonLog = $builder
|
||||||
$null = $builder.Append($r.remote_ip)
|
.Clear()
|
||||||
$null = $builder.Append(" - [")
|
.Append($r.remote_ip)
|
||||||
$null = $builder.Append($baseDate.AddSeconds($l.ts).ToString("yyyy-MM-dd HH:mm:ss.fff"))
|
.Append(" - [")
|
||||||
$null = $builder.Append("] """)
|
.Append($baseDate.AddSeconds($l.ts).ToString("yyyy-MM-dd HH:mm:ss.fff"))
|
||||||
$null = $builder.Append($r.host)
|
.Append("] """)
|
||||||
$null = $builder.Append(""" ")
|
.Append($r.host)
|
||||||
$null = $builder.Append($r.method)
|
.Append(""" ")
|
||||||
$null = $builder.Append(" ")
|
.Append($r.method)
|
||||||
$null = $builder.Append($r.uri)
|
.Append(" ")
|
||||||
$null = $builder.Append(" ")
|
.Append($r.uri)
|
||||||
$null = $builder.Append($r.proto)
|
.Append(" ")
|
||||||
$null = $builder.Append(" ")
|
.Append($r.proto)
|
||||||
$null = $builder.Append($l.status)
|
.Append(" ")
|
||||||
$null = $builder.Append(" ")
|
.Append($l.status)
|
||||||
$null = $builder.Append($l.size)
|
.Append(" ")
|
||||||
$null = $builder.Append(" """)
|
.Append($l.size)
|
||||||
$null = $builder.Append($referer)
|
.Append(" """)
|
||||||
$null = $builder.Append(""" """)
|
.Append($referer)
|
||||||
$null = $builder.Append($userAgent)
|
.Append(""" """)
|
||||||
$null = $builder.Append("""")
|
.Append($userAgent)
|
||||||
|
.Append("""")
|
||||||
$commonLog = $builder.ToString()
|
.ToString()
|
||||||
|
|
||||||
Write-Output $commonLog
|
Write-Output $commonLog
|
||||||
$outputWriter.WriteLine($commonLog)
|
$outputWriter.WriteLine($commonLog)
|
||||||
$outputWriter.Flush()
|
$outputWriter.Flush()
|
||||||
|
|
||||||
#[system.string]::Join(
|
|
||||||
# " ",
|
|
||||||
# @(
|
|
||||||
# "$($r.remote_ip) - [$($baseDate.AddSeconds($l.ts).ToString("yyyy-MM-dd HH:mm:ss.fff"))]",
|
|
||||||
# """$($r.host)""",
|
|
||||||
# $r.method,
|
|
||||||
# $r.uri,
|
|
||||||
# $r.proto,
|
|
||||||
# $l.status,
|
|
||||||
# $l.size,
|
|
||||||
# """$($r.headers.Referer)""",
|
|
||||||
# """$ua"""
|
|
||||||
# ))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue