mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-07 21:46:37 +00:00
fix: use log.file=eventlog as default value, if running as windows service (#1771)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -105,7 +105,14 @@ func run() int {
|
||||
).Default("normal").String()
|
||||
)
|
||||
|
||||
logConfig := &log.Config{}
|
||||
logFile := &log.AllowedFile{}
|
||||
|
||||
_ = logFile.Set("stdout")
|
||||
if windowsservice.IsService {
|
||||
_ = logFile.Set("eventlog")
|
||||
}
|
||||
|
||||
logConfig := &log.Config{File: logFile}
|
||||
flag.AddFlags(app, logConfig)
|
||||
|
||||
app.Version(version.Print("windows_exporter"))
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
||||
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
|
||||
<Wix xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
|
||||
xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||
<Fragment>
|
||||
<DirectoryRef Id="APPLICATIONFOLDER">
|
||||
<Component Transitive="yes">
|
||||
@@ -28,7 +28,7 @@
|
||||
Start="auto"
|
||||
Type="ownProcess"
|
||||
Vital="yes"
|
||||
Arguments="--log.file eventlog [ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
||||
Arguments="[ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
||||
<util:ServiceConfig
|
||||
ResetPeriodInDays="1"
|
||||
FirstFailureActionType="restart"
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
||||
xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
|
||||
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
|
||||
<Wix xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
|
||||
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
|
||||
xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="$(var.ProductName)" Version="$(var.Version)"
|
||||
Manufacturer="prometheus-community" Language="1033" Scope="perMachine">
|
||||
<SummaryInformation Manufacturer="prometheus-community" Description="$(var.ProductName) $(var.Version) installer" />
|
||||
|
||||
@@ -34,6 +34,9 @@ func AddFlags(a *kingpin.Application, config *log.Config) {
|
||||
config.Config = new(promslog.Config)
|
||||
flag.AddFlags(a, config.Config)
|
||||
|
||||
config.File = &log.AllowedFile{}
|
||||
a.Flag(FileFlagName, FileFlagHelp).Default("stderr").SetValue(config.File)
|
||||
if config.File == nil {
|
||||
config.File = &log.AllowedFile{}
|
||||
}
|
||||
|
||||
a.Flag(FileFlagName, FileFlagHelp).Default(config.File.String()).SetValue(config.File)
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ type AllowedFile struct {
|
||||
}
|
||||
|
||||
func (f *AllowedFile) String() string {
|
||||
if f == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return f.s
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user