Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
c1aa059d
Commit
c1aa059d
authored
Jul 13, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #168 from markpeek/markpeek-filelogging
Add ability to send log output to a file using PACKER_LOG_PATH
parents
0e9c0eda
1d22f2ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
packer.go
packer.go
+14
-2
No files found.
packer.go
View file @
c1aa059d
...
...
@@ -14,12 +14,24 @@ import (
)
func
main
()
{
// Setup logging if PACKER_LOG is set.
// Log to PACKER_LOG_PATH if it is set, otherwise default to stderr.
if
os
.
Getenv
(
"PACKER_LOG"
)
==
""
{
// If we don't have logging explicitly enabled, then disable it
log
.
SetOutput
(
ioutil
.
Discard
)
}
else
{
// Logging is enabled, make sure it goes to stderr
log
.
SetOutput
(
os
.
Stderr
)
if
log_path
:=
os
.
Getenv
(
"PACKER_LOG_PATH"
);
log_path
==
""
{
log
.
SetOutput
(
os
.
Stderr
)
}
else
{
file
,
err
:=
os
.
OpenFile
(
log_path
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0600
)
if
err
==
nil
{
log
.
SetOutput
(
file
)
}
else
{
// Problem opening the file, fail back to Stderr
log
.
SetOutput
(
os
.
Stderr
)
log
.
Printf
(
"Could not open %s for logging (%s). Using stderr instead."
,
log_path
,
err
.
Error
())
}
}
}
// If there is no explicit number of Go threads to use, then set it
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment