- use logger

This commit is contained in:
Alex Ling
2020-02-16 21:24:19 +00:00
parent bb936b1fa6
commit 7168c6bfb2
10 changed files with 125 additions and 40 deletions

View File

@@ -16,10 +16,7 @@ def random_str
end
class Storage
property path : String
def initialize(path)
@path = path
def initialize(@path : String, @logger : MLogger)
dir = File.dirname path
unless Dir.exists? dir
Dir.mkdir_p dir
@@ -39,7 +36,7 @@ class Storage
hash = hash_password random_pw
db.exec "insert into users values (?, ?, ?, ?)",
"admin", hash, nil, 1
puts "Initial user created. You can log in with " \
@logger.info "Initial user created. You can log in with " \
"#{{"username" => "admin", "password" => random_pw}}"
end
end