Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
a6b63260
Commit
a6b63260
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add Log-Warning(), use Category 100 for all log entries.
Plus, use Id numbers matching default output redirection ones.
parent
407b6ff1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Updater/Update-Service.ps1
+22
-15
22 additions, 15 deletions
Updater/Update-Service.ps1
with
22 additions
and
15 deletions
Updater/Update-Service.ps1
+
22
−
15
View file @
a6b63260
...
...
@@ -333,31 +333,38 @@ function Send-MailReport([string]$Subject, [string]$Body) {
function
Log
-Message
([
string
]
$Type
,
[
string
]
$Message
,
[
int
]
$Id
){
$msg
=
"[
$(
$Me
)
] "
try
{
Write-EventLog
`
# NOTE: by convention, this script is setting the $Id parameter to match the
# numbers for the output types described in 'Help about_Redirection'
$msg
=
"[
$(
$Me
)
] "
try
{
Write-EventLog
`
-LogName
Application
`
-Source
"AutoTx"
`
-Category
0
`
-Source
$ServiceName
`
-Category
10
0
`
-EventId
$Id
`
-EntryType
$Type
`
-Message
"[
$(
$Me
)
]:
$(
$Message
)
"
`
-ErrorAction
Stop
$msg
+=
"Logged message (Id=
$(
$Id
)
, Type=
$(
$Type
)
).
`n
"
$msg
+=
"--- Log Message ---
`n
$(
$Message
)
`n
--- Log Message ---
`n
"
}
catch
{
$ex
=
$_
.
Exception
.
Message
$msg
+=
"Error logging message (Id=
$(
$Id
)
, Type=
$(
$Type
)
)!
`n
"
$msg
+=
"--- Log Message ---
`n
$(
$Message
)
`n
--- Log Message ---
`n
"
$msg
+=
"--- Exception ---
`n
$(
$ex
)
`n
--- Exception ---"
}
Write-Verbose
$msg
}
catch
{
$ex
=
$_
.
Exception
.
Message
$msg
+=
"Error logging message (Id=
$(
$Id
)
, Type=
$(
$Type
)
)!
`n
"
$msg
+=
"--- Log Message ---
`n
$(
$Message
)
`n
--- Log Message ---
`n
"
$msg
+=
"--- Exception ---
`n
$(
$ex
)
`n
--- Exception ---"
}
Write-Verbose
$msg
}
function
Log
-Warning
([
string
]
$Message
)
{
Log-Message
-Type
Warning
-Message
$Message
-Id
3
}
function
Log
-Error
([
string
]
$Message
){
Log-Message
-Type
Error
-Message
$Message
-Id
1
Log-Message
-Type
Error
-Message
$Message
-Id
2
}
...
...
@@ -369,7 +376,7 @@ function Log-Info([string]$Message) {
function
Log
-Debug
([
string
]
$Message
)
{
Write-Verbose
$Message
if
(
$UpdaterDebugLogging
)
{
Log-Message
-Type
Information
-Message
$Message
-Id
1000
Log-Message
-Type
Information
-Message
$Message
-Id
5
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment