Skip to content

Commit 1eab154

Browse files
authored
[Prefix] Add subdir argument to logdir function (#146)
1 parent 10ed138 commit 1eab154

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <staticfloat@gmail.com>"]
4-
version = "0.6.4"
4+
version = "0.6.5"
55

66
[deps]
77
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"

src/Prefix.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ function includedir(prefix::Prefix)
109109
end
110110

111111
"""
112-
logdir(prefix::Prefix)
112+
logdir(prefix::Prefix; subdir::AbstractString="")
113113
114-
Returns the logs directory for the given `prefix`.
114+
Returns the logs directory for the given `prefix`. If `subdir` is a non-empty string, that
115+
directory it is appended to the logdir of the given `prefix`.
115116
"""
116-
function logdir(prefix::Prefix)
117-
return joinpath(prefix, "logs")
117+
function logdir(prefix::Prefix; subdir::AbstractString="")
118+
return strip_backslash(joinpath(prefix, "logs", subdir))
118119
end
119120

120121
"""

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The functions in this file may not be used anywhere in this package but may
22
# needed by different modules of BinaryBuilder.jl
33

4-
with_logfile(f::Function, prefix::Prefix, name::String) = with_logfile(f, joinpath(logdir(prefix), name))
4+
with_logfile(f::Function, prefix::Prefix, name::String; subdir="") = with_logfile(f, joinpath(logdir(prefix; subdir), name))
55
function with_logfile(f::Function, logfile::String)
66
mkpath(dirname(logfile))
77

test/prefix.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using CodecZlib
3232
@test bindir(prefix) == joinpath(prefix, "bin")
3333
@test includedir(prefix) == joinpath(prefix, "include")
3434
@test logdir(prefix) == joinpath(prefix, "logs")
35+
@test logdir(prefix; subdir="test") == joinpath(prefix, "logs", "test")
3536
end
3637
end
3738

0 commit comments

Comments
 (0)