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
|
||||
$referer = $r.headers.Referer | Select-Object -First 1
|
||||
|
||||
$null = $builder.Clear()
|
||||
$null = $builder.Append($r.remote_ip)
|
||||
$null = $builder.Append(" - [")
|
||||
$null = $builder.Append($baseDate.AddSeconds($l.ts).ToString("yyyy-MM-dd HH:mm:ss.fff"))
|
||||
$null = $builder.Append("] """)
|
||||
$null = $builder.Append($r.host)
|
||||
$null = $builder.Append(""" ")
|
||||
$null = $builder.Append($r.method)
|
||||
$null = $builder.Append(" ")
|
||||
$null = $builder.Append($r.uri)
|
||||
$null = $builder.Append(" ")
|
||||
$null = $builder.Append($r.proto)
|
||||
$null = $builder.Append(" ")
|
||||
$null = $builder.Append($l.status)
|
||||
$null = $builder.Append(" ")
|
||||
$null = $builder.Append($l.size)
|
||||
$null = $builder.Append(" """)
|
||||
$null = $builder.Append($referer)
|
||||
$null = $builder.Append(""" """)
|
||||
$null = $builder.Append($userAgent)
|
||||
$null = $builder.Append("""")
|
||||
|
||||
$commonLog = $builder.ToString()
|
||||
$commonLog = $builder
|
||||
.Clear()
|
||||
.Append($r.remote_ip)
|
||||
.Append(" - [")
|
||||
.Append($baseDate.AddSeconds($l.ts).ToString("yyyy-MM-dd HH:mm:ss.fff"))
|
||||
.Append("] """)
|
||||
.Append($r.host)
|
||||
.Append(""" ")
|
||||
.Append($r.method)
|
||||
.Append(" ")
|
||||
.Append($r.uri)
|
||||
.Append(" ")
|
||||
.Append($r.proto)
|
||||
.Append(" ")
|
||||
.Append($l.status)
|
||||
.Append(" ")
|
||||
.Append($l.size)
|
||||
.Append(" """)
|
||||
.Append($referer)
|
||||
.Append(""" """)
|
||||
.Append($userAgent)
|
||||
.Append("""")
|
||||
.ToString()
|
||||
|
||||
Write-Output $commonLog
|
||||
$outputWriter.WriteLine($commonLog)
|
||||
$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