@@ -33,18 +33,21 @@ var (
3333 }
3434)
3535
36+ func configureLogFile () {
37+ p := project .GetProject ()
38+ logger := shell .GetLogger ()
39+ logger .AddHandler (shell .NewFileLogHandler (filepath .Join (p .GetDirectory (), "var" , "log" , "kyx.log" )))
40+ }
41+
3642func main () {
3743 cmds := append (commands .GetCommands (), tools .GetCommands (toolsMapping )... )
3844 cmds = append (cmds , tools .CreateCommand ("test" ))
3945 toolNames := tools .GetNames (toolsMapping )
4046
41- p := project .GetProject ()
42- logger := shell .GetLogger ()
43- logger .AddHandler (shell .NewFileLogHandler (filepath .Join (p .GetDirectory (), "var" , "log" , "kyx.log" )))
44-
4547 args := os .Args
4648
4749 if len (args ) >= 2 && slices .Contains (toolNames , args [1 ]) {
50+ configureLogFile ()
4851 cmd := tools .NewToolCommand (args [1 ], toolsMapping , args [2 :]... )
4952
5053 if err := cmd .Run (); err != nil {
@@ -56,6 +59,7 @@ func main() {
5659 }
5760
5861 if len (args ) >= 2 && args [1 ] == "test" {
62+ configureLogFile ()
5963 p := project .GetProject ()
6064 pd := p .GetDirectory ()
6165
@@ -89,9 +93,13 @@ func main() {
8993 Usage : "kyx [command] [options]" ,
9094 Copyright : fmt .Sprintf ("(c) 2025-%d Jason Schilling" , time .Now ().Year ()),
9195 Commands : cmds ,
92- Before : func (context * console.Context ) error {
96+ Before : func (ctx * console.Context ) error {
9397 shell .GetConsoleLogHandler ().SetLogLevel (terminal .GetLogLevel ())
9498
99+ if ctx .Command != nil {
100+ configureLogFile ()
101+ }
102+
95103 return nil
96104 },
97105 Action : func (ctx * console.Context ) error {
0 commit comments