feature(desktop/internal): Improve log file naming convention

Logs are named app_yyyyMMdd_HHmmss.log
Version, commit and start date information are displayed in logs at the begining.
Injecting commit version from Makefile.
Moving DESKTOP_VERSION const to constants.nim

Fix #3611
This commit is contained in:
Michal Iskierko 2022-03-24 12:51:24 +01:00 committed by Iuri Matias
parent cfd84d5ba0
commit 3711ab613a
4 changed files with 15 additions and 4 deletions

View File

@ -195,6 +195,9 @@ VERSIONFILE=VERSION
DESKTOP_VERSION=`cat $(VERSIONFILE)`
NIM_PARAMS += -d:DESKTOP_VERSION="$(DESKTOP_VERSION)"
GIT_COMMIT=`git log --pretty=format:'%h' -n 1`
NIM_PARAMS += -d:GIT_COMMIT="$(GIT_COMMIT)"
$(DOTHERSIDE): | deps
echo -e $(BUILD_MSG) "DOtherSide"
+ cd vendor/DOtherSide && \

View File

@ -2,6 +2,7 @@ import NimQml, json, chronicles
import ../../../app/core/eventemitter
import ../../../app/core/tasks/[qt, threadpool]
import ../../../constants
import ../settings/service as settings_service
import ../network/types
@ -13,9 +14,6 @@ include async_tasks
logScope:
topics = "about-service"
# This is changed during compilation by reading the VERSION file
const DESKTOP_VERSION {.strdefine.} = "0.0.0"
type
VersionArgs* = ref object of Args
version*: string

View File

@ -64,3 +64,8 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) =
createDir(dataDir)
createDir(tmpDir)
createDir(logDir)
# This is changed during compilation by reading the VERSION file
const DESKTOP_VERSION* {.strdefine.} = "0.0.0"
# This is changed during compilation by executing git command
const GIT_COMMIT* {.strdefine.} = ""

View File

@ -49,7 +49,8 @@ proc prepareLogging() =
except:
logLoggingFailure(cstring(msg), getCurrentException())
let logFile = fmt"app_{getTime().toUnix}.log"
let formattedDate = now().format("yyyyMMdd'_'HHmmss")
let logFile = fmt"app_{formattedDate}.log"
discard defaultChroniclesStream.outputs[1].open(LOGDIR & logFile, fmAppend)
proc setupRemoteSignalsHandling() =
@ -134,6 +135,10 @@ proc mainProc() =
info "Terminating the app as the second instance"
quit()
info fmt("Version: {DESKTOP_VERSION}")
info fmt("Commit: {GIT_COMMIT}")
info "Current date:", currentDateTime=now()
info "starting application controller..."
appController.start()