Skip to content

Commit

Permalink
update file path setting
Browse files Browse the repository at this point in the history
  • Loading branch information
xuestrange committed Oct 11, 2023
1 parent 0abc727 commit 55294a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using Log2file
# set the length of seperator line
Log2file.set_line_length!(40)
# set the relative directory logfile
Log2file.set_logfile_path!("./test/test.txt")
Log2file.set_logfile_path!("test", "test.txt")

# create the th log file if not existed, otherwise, empty it; add a line of program begins
@init_log
Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_LINE_LENGTH = 40
_LOGFILE_PATH = "C:/"
_LOGFILE_PATH = joinpath(pwd(), "test.txt")
"""
Initialize you log file. Usually used at the beginning of you programs, the macro will create a file with one line indicating the beginning of the program.
"""
Expand All @@ -16,8 +16,8 @@ Create a global variable named `_LOGFILE_PATH= path`
# Arguments
+ `path`: string
"""
function set_logfile_path!(path)
global _LOGFILE_PATH= path
function set_logfile_path!(path...)
global _LOGFILE_PATH= joinpath(pwd(), path...)
@info "A global variable is created: _LOGFILE_PATH = \"$_LOGFILE_PATH\""
end
function set_line_length!(l::Int64)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Log2file
using Test
Log2file.set_line_length!(40)
Log2file.set_logfile_path!("./test/test.txt")
Log2file.set_logfile_path!("test", "test.txt")
function test_log2file()
@init_log
@section "Step 1: Data Generation"
Expand Down
10 changes: 5 additions & 5 deletions test/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2023-10-11 22:09:37 =============PROGRAM BEGINS=============
2023-10-11 22:09:37 ========Step 1: Data Generation=========
2023-10-11 22:09:37 a = [1, 2, 3]
2023-10-11 22:09:37 a = [1, 2, 3], b = [0.375927 -0.317262; -1.560876 -2.144288]
2023-10-11 22:09:37 ==================END===================
2023-10-11 22:17:02 =============PROGRAM BEGINS=============
2023-10-11 22:17:02 ========Step 1: Data Generation=========
2023-10-11 22:17:02 a = [1, 2, 3]
2023-10-11 22:17:02 a = [1, 2, 3], b = [0.375927 -0.317262; -1.560876 -2.144288]
2023-10-11 22:17:02 ==================END===================

0 comments on commit 55294a0

Please sign in to comment.