diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index a578ff0b6..c57d50dd7 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -2,19 +2,19 @@ package build import ( "fmt" - "os" + "io" "runtime" "strings" "time" "github.com/leaanthony/clir" "github.com/leaanthony/slicer" - "github.com/wailsapp/wails/v2/internal/logger" + "github.com/wailsapp/wails/v2/pkg/clilogger" "github.com/wailsapp/wails/v2/pkg/commands/build" ) // AddBuildSubcommand adds the `build` command for the Wails application -func AddBuildSubcommand(app *clir.Cli) { +func AddBuildSubcommand(app *clir.Cli, w io.Writer) { outputType := "desktop" @@ -56,11 +56,8 @@ func AddBuildSubcommand(app *clir.Cli) { command.Action(func() error { // Create logger - logger := logger.New() - - if !quiet { - logger.AddOutput(os.Stdout) - } + logger := clilogger.New(w) + logger.Mute(quiet) // Validate output type if !validTargetTypes.Contains(outputType) { @@ -72,8 +69,8 @@ func AddBuildSubcommand(app *clir.Cli) { } task := fmt.Sprintf("Building %s Application", strings.Title(outputType)) - logger.Writeln(task) - logger.Writeln(strings.Repeat("-", len(task))) + logger.Println(task) + logger.Println(strings.Repeat("-", len(task))) // Setup mode mode := build.Debug @@ -108,9 +105,9 @@ func doBuild(buildOptions *build.Options) error { } // Output stats elapsed := time.Since(start) - buildOptions.Logger.Writeln("") - buildOptions.Logger.Writeln(fmt.Sprintf("Built '%s' in %s.", outputFilename, elapsed.Round(time.Millisecond).String())) - buildOptions.Logger.Writeln("") + buildOptions.Logger.Println("") + buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.", outputFilename, elapsed.Round(time.Millisecond).String())) + buildOptions.Logger.Println("") return nil } diff --git a/v2/cmd/wails/internal/commands/dev/dev.go b/v2/cmd/wails/internal/commands/dev/dev.go index aeadade14..a9fe17890 100644 --- a/v2/cmd/wails/internal/commands/dev/dev.go +++ b/v2/cmd/wails/internal/commands/dev/dev.go @@ -2,6 +2,7 @@ package dev import ( "fmt" + "io" "os" "os/signal" "runtime" @@ -13,13 +14,13 @@ import ( "github.com/leaanthony/clir" "github.com/leaanthony/slicer" "github.com/wailsapp/wails/v2/internal/fs" - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/process" + "github.com/wailsapp/wails/v2/pkg/clilogger" "github.com/wailsapp/wails/v2/pkg/commands/build" ) // AddSubcommand adds the `dev` command for the Wails application -func AddSubcommand(app *clir.Cli) error { +func AddSubcommand(app *clir.Cli, w io.Writer) error { command := app.NewSubCommand("dev", "Development mode") @@ -51,8 +52,7 @@ func AddSubcommand(app *clir.Cli) error { } // Create logger - logger := logger.New() - logger.AddOutput(os.Stdout) + logger := clilogger.New(w) app.PrintBanner() // TODO: Check you are in a project directory @@ -74,11 +74,11 @@ func AddSubcommand(app *clir.Cli) error { debounceQuit := make(chan bool, 1) // Do initial build - logger.Info("Building application for development...") + logger.Println("Building application for development...") debugBinaryProcess = restartApp(logger, outputType, ldflags, compilerCommand, buildFrontend, debugBinaryProcess) go debounce(100*time.Millisecond, watcher.Events, debounceQuit, func(event fsnotify.Event) { - // logger.Info("event: %+v", event) + // logger.Println("event: %+v", event) // Check for new directories if event.Op&fsnotify.Create == fsnotify.Create { @@ -86,7 +86,7 @@ func AddSubcommand(app *clir.Cli) error { if fs.DirExists(event.Name) { if !strings.Contains(event.Name, "node_modules") { watcher.Add(event.Name) - logger.Info("Watching directory: %s", event.Name) + logger.Println("Watching directory: %s", event.Name) } } return @@ -95,7 +95,7 @@ func AddSubcommand(app *clir.Cli) error { // Check for file writes if event.Op&fsnotify.Write == fsnotify.Write { - // logger.Info("modified file: %s", event.Name) + // logger.Println("modified file: %s", event.Name) var rebuild bool = false // Iterate all file patterns @@ -112,14 +112,14 @@ func AddSubcommand(app *clir.Cli) error { } if !rebuild { - logger.Info("Filename change: %s did not match extension list %s", event.Name, extensions) + logger.Println("Filename change: %s did not match extension list %s", event.Name, extensions) return } if buildFrontend { - logger.Info("Full rebuild triggered: %s updated", event.Name) + logger.Println("Full rebuild triggered: %s updated", event.Name) } else { - logger.Info("Partial build triggered: %s updated", event.Name) + logger.Println("Partial build triggered: %s updated", event.Name) } // Do a rebuild @@ -152,7 +152,7 @@ func AddSubcommand(app *clir.Cli) error { if strings.Contains(dir, "node_modules") { return } - logger.Info("Watching directory: %s", dir) + logger.Println("Watching directory: %s", dir) err = watcher.Add(dir) if err != nil { logger.Fatal(err.Error()) @@ -176,7 +176,7 @@ func AddSubcommand(app *clir.Cli) error { debugBinaryProcess.Kill() } - logger.Info("Development mode exited") + logger.Println("Development mode exited") return nil }) @@ -203,15 +203,15 @@ exit: } } -func restartApp(logger *logger.Logger, outputType string, ldflags string, compilerCommand string, buildFrontend bool, debugBinaryProcess *process.Process) *process.Process { +func restartApp(logger *clilogger.CLILogger, outputType string, ldflags string, compilerCommand string, buildFrontend bool, debugBinaryProcess *process.Process) *process.Process { appBinary, err := buildApp(logger, outputType, ldflags, compilerCommand, buildFrontend) println() if err != nil { - logger.Error("Build Failed: %s", err.Error()) + logger.Println("[ERROR] Build Failed: %s", err.Error()) return nil } - logger.Info("Build new binary: %s", appBinary) + logger.Println("Build new binary: %s", appBinary) // Kill existing binary if need be if debugBinaryProcess != nil { @@ -238,7 +238,7 @@ func restartApp(logger *logger.Logger, outputType string, ldflags string, compil return newProcess } -func buildApp(logger *logger.Logger, outputType string, ldflags string, compilerCommand string, buildFrontend bool) (string, error) { +func buildApp(logger *clilogger.CLILogger, outputType string, ldflags string, compilerCommand string, buildFrontend bool) (string, error) { // Create random output file outputFile := fmt.Sprintf("debug-%d", time.Now().Unix()) diff --git a/v2/cmd/wails/internal/commands/doctor/doctor.go b/v2/cmd/wails/internal/commands/doctor/doctor.go index b0f6df45d..27d310c94 100644 --- a/v2/cmd/wails/internal/commands/doctor/doctor.go +++ b/v2/cmd/wails/internal/commands/doctor/doctor.go @@ -2,37 +2,37 @@ package doctor import ( "fmt" + "io" + "log" "os" "runtime" "strings" "text/tabwriter" "github.com/leaanthony/clir" - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/system" "github.com/wailsapp/wails/v2/internal/system/packagemanager" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // AddSubcommand adds the `doctor` command for the Wails application -func AddSubcommand(app *clir.Cli) error { +func AddSubcommand(app *clir.Cli, w io.Writer) error { command := app.NewSubCommand("doctor", "Diagnose your environment") command.Action(func() error { - // Create logger - logger := logger.New() - logger.AddOutput(os.Stdout) + logger := clilogger.New(w) app.PrintBanner() - print("Scanning system - please wait...") + logger.Print("Scanning system - please wait...") // Get system info info, err := system.GetInfo() if err != nil { return err } - println("Done.") + logger.Println("Done.") // Start a new tabwriter w := new(tabwriter.Writer) @@ -112,22 +112,22 @@ func AddSubcommand(app *clir.Cli) error { fmt.Fprintf(w, "\n") fmt.Fprintf(w, "* - Optional Dependency\n") w.Flush() - println() - println("Diagnosis") - println("---------\n") + logger.Println("") + logger.Println("Diagnosis") + logger.Println("---------\n") // Generate an appropriate diagnosis if len(dependenciesMissing) == 0 && dependenciesAvailableRequired == 0 { - println("Your system is ready for Wails development!") + logger.Println("Your system is ready for Wails development!") } if dependenciesAvailableRequired != 0 { - println("Install required packages using: " + info.Dependencies.InstallAllRequiredCommand()) + log.Println("Install required packages using: " + info.Dependencies.InstallAllRequiredCommand()) } if dependenciesAvailableOptional != 0 { - println("Install optional packages using: " + info.Dependencies.InstallAllOptionalCommand()) + log.Println("Install optional packages using: " + info.Dependencies.InstallAllOptionalCommand()) } if len(externalPackages) > 0 { @@ -135,18 +135,18 @@ func AddSubcommand(app *clir.Cli) error { if p.Optional { print("[Optional] ") } - println("Install " + p.Name + ": " + p.InstallCommand) + log.Println("Install " + p.Name + ": " + p.InstallCommand) } } if len(dependenciesMissing) != 0 { // TODO: Check if apps are available locally and if so, adjust the diagnosis - println("Fatal:") - println("Required dependencies missing: " + strings.Join(dependenciesMissing, " ")) - println("Please read this article on how to resolve this: https://wails.app/guides/resolving-missing-packages") + log.Println("Fatal:") + log.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " ")) + log.Println("Please read this article on how to resolve this: https://wails.app/guides/resolving-missing-packages") } - println() + log.Println("") return nil }) diff --git a/v2/cmd/wails/internal/commands/initialise/initialise.go b/v2/cmd/wails/internal/commands/initialise/initialise.go index 55217aa77..6bb7e785f 100644 --- a/v2/cmd/wails/internal/commands/initialise/initialise.go +++ b/v2/cmd/wails/internal/commands/initialise/initialise.go @@ -2,17 +2,17 @@ package initialise import ( "fmt" - "os" + "io" "strings" "time" "github.com/leaanthony/clir" - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/templates" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // AddSubcommand adds the `init` command for the Wails application -func AddSubcommand(app *clir.Cli) error { +func AddSubcommand(app *clir.Cli, w io.Writer) error { // Load the template shortnames validShortNames, err := templates.TemplateShortNames() @@ -46,32 +46,29 @@ func AddSubcommand(app *clir.Cli) error { command.Action(func() error { // Create logger - logger := logger.New() - - if !quiet { - logger.AddOutput(os.Stdout) - } + logger := clilogger.New(w) + logger.Mute(quiet) // Are we listing templates? if list { app.PrintBanner() err := templates.OutputList(logger) - logger.Writeln("") + logger.Println("") return err } // Validate output type if !validShortNames.Contains(templateName) { - logger.Write(fmt.Sprintf("ERROR: Template '%s' is not valid", templateName)) - logger.Writeln("") + logger.Print(fmt.Sprintf("[ERROR] Template '%s' is not valid", templateName)) + logger.Println("") command.PrintHelp() return nil } // Validate name if len(projectName) == 0 { - logger.Writeln("ERROR: Project name required") - logger.Writeln("") + logger.Println("ERROR: Project name required") + logger.Println("") command.PrintHelp() return nil } @@ -81,8 +78,8 @@ func AddSubcommand(app *clir.Cli) error { } task := fmt.Sprintf("Initialising Project %s", strings.Title(projectName)) - logger.Writeln(task) - logger.Writeln(strings.Repeat("-", len(task))) + logger.Println(task) + logger.Println(strings.Repeat("-", len(task))) // Create Template Options options := &templates.Options{ @@ -112,9 +109,9 @@ func initProject(options *templates.Options) error { // Output stats elapsed := time.Since(start) - options.Logger.Writeln("") - options.Logger.Writeln(fmt.Sprintf("Initialised project '%s' in %s.", options.ProjectName, elapsed.Round(time.Millisecond).String())) - options.Logger.Writeln("") + options.Logger.Println("") + options.Logger.Println(fmt.Sprintf("Initialised project '%s' in %s.", options.ProjectName, elapsed.Round(time.Millisecond).String())) + options.Logger.Println("") return nil } diff --git a/v2/cmd/wails/main.go b/v2/cmd/wails/main.go index d1e320a41..4d9bd4baf 100644 --- a/v2/cmd/wails/main.go +++ b/v2/cmd/wails/main.go @@ -22,17 +22,17 @@ func main() { app := clir.NewCli("Wails", "Go/HTML Application Framework", version) - build.AddBuildSubcommand(app) - err = initialise.AddSubcommand(app) + build.AddBuildSubcommand(app, os.Stdout) + err = initialise.AddSubcommand(app, os.Stdout) if err != nil { fatal(err.Error()) } - err = doctor.AddSubcommand(app) + err = doctor.AddSubcommand(app, os.Stdout) if err != nil { fatal(err.Error()) } - err = dev.AddSubcommand(app) + err = dev.AddSubcommand(app, os.Stdout) if err != nil { fatal(err.Error()) } diff --git a/v2/internal/process/process.go b/v2/internal/process/process.go index 4a92e8fd9..e6a925b56 100644 --- a/v2/internal/process/process.go +++ b/v2/internal/process/process.go @@ -3,19 +3,19 @@ package process import ( "os/exec" - "github.com/wailsapp/wails/v2/internal/logger" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // Process defines a process that can be executed type Process struct { - logger *logger.Logger + logger *clilogger.CLILogger cmd *exec.Cmd exitChannel chan bool Running bool } // NewProcess creates a new process struct -func NewProcess(logger *logger.Logger, cmd string, args ...string) *Process { +func NewProcess(logger *clilogger.CLILogger, cmd string, args ...string) *Process { return &Process{ logger: logger, cmd: exec.Command(cmd, args...), @@ -33,10 +33,10 @@ func (p *Process) Start() error { p.Running = true - go func(cmd *exec.Cmd, running *bool, logger *logger.Logger, exitChannel chan bool) { - logger.Info("Starting process (PID: %d)", cmd.Process.Pid) + go func(cmd *exec.Cmd, running *bool, logger *clilogger.CLILogger, exitChannel chan bool) { + logger.Println("Starting process (PID: %d)", cmd.Process.Pid) cmd.Wait() - logger.Info("Exiting process (PID: %d)", cmd.Process.Pid) + logger.Println("Exiting process (PID: %d)", cmd.Process.Pid) *running = false exitChannel <- true }(p.cmd, &p.Running, p.logger, p.exitChannel) diff --git a/v2/internal/templates/templates.go b/v2/internal/templates/templates.go index a52401df0..06dd1f5db 100644 --- a/v2/internal/templates/templates.go +++ b/v2/internal/templates/templates.go @@ -12,7 +12,7 @@ import ( "github.com/leaanthony/slicer" "github.com/olekukonko/tablewriter" "github.com/wailsapp/wails/v2/internal/fs" - "github.com/wailsapp/wails/v2/internal/logger" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // Cahce for the templates @@ -35,7 +35,7 @@ type Options struct { TemplateName string BinaryName string TargetDir string - Logger *logger.Logger + Logger *clilogger.CLILogger } // Template holds data relating to a template @@ -218,30 +218,28 @@ func Install(options *Options) error { } // OutputList prints the list of available tempaltes to the given logger -func OutputList(logger *logger.Logger) error { +func OutputList(logger *clilogger.CLILogger) error { templates, err := List() if err != nil { return err } - for _, writer := range logger.Writers() { - table := tablewriter.NewWriter(writer) - table.SetHeader([]string{"Template", "Short Name", "Description"}) - table.SetAutoWrapText(false) - table.SetAutoFormatHeaders(true) - table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) - table.SetAlignment(tablewriter.ALIGN_LEFT) - table.SetCenterSeparator("") - table.SetColumnSeparator("") - table.SetRowSeparator("") - table.SetHeaderLine(false) - table.SetBorder(false) - table.SetTablePadding("\t") // pad with tabs - table.SetNoWhiteSpace(true) - for _, template := range templates { - table.Append([]string{template.Name, template.ShortName, template.Description}) - } - table.Render() + table := tablewriter.NewWriter(logger.Writer) + table.SetHeader([]string{"Template", "Short Name", "Description"}) + table.SetAutoWrapText(false) + table.SetAutoFormatHeaders(true) + table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) + table.SetAlignment(tablewriter.ALIGN_LEFT) + table.SetCenterSeparator("") + table.SetColumnSeparator("") + table.SetRowSeparator("") + table.SetHeaderLine(false) + table.SetBorder(false) + table.SetTablePadding("\t") // pad with tabs + table.SetNoWhiteSpace(true) + for _, template := range templates { + table.Append([]string{template.Name, template.ShortName, template.Description}) } + table.Render() return nil } diff --git a/v2/pkg/clilogger/clilogger.go b/v2/pkg/clilogger/clilogger.go new file mode 100644 index 000000000..a123e83a1 --- /dev/null +++ b/v2/pkg/clilogger/clilogger.go @@ -0,0 +1,59 @@ +package clilogger + +import ( + "fmt" + "io" + "os" +) + +// CLILogger is used by the cli +type CLILogger struct { + Writer io.Writer + mute bool +} + +// New cli logger +func New(writer io.Writer) *CLILogger { + return &CLILogger{ + Writer: writer, + } +} + +// Mute sets whether the logger should be muted +func (c *CLILogger) Mute(value bool) { + c.mute = value +} + +// Print works like Printf +func (c *CLILogger) Print(message string, args ...interface{}) { + if c.mute { + return + } + + _, err := fmt.Fprintf(c.Writer, message, args...) + if err != nil { + c.Fatal("Fatal: ", err) + } +} + +// Println works like Printf but with a line ending +func (c *CLILogger) Println(message string, args ...interface{}) { + if c.mute { + return + } + temp := fmt.Sprintf(message, args...) + _, err := fmt.Fprintln(c.Writer, temp) + if err != nil { + c.Fatal("Fatal: ", err) + } +} + +// Fatal prints the given message then aborts +func (c *CLILogger) Fatal(message string, args ...interface{}) { + temp := fmt.Sprintf(message, args...) + _, err := fmt.Fprintln(c.Writer, "FATAL: "+temp) + if err != nil { + println("FATAL: ", err) + } + os.Exit(1) +} diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 9c1707d2a..a6e09f544 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -14,9 +14,9 @@ import ( "github.com/wailsapp/wails/v2/internal/assetdb" "github.com/wailsapp/wails/v2/internal/fs" "github.com/wailsapp/wails/v2/internal/html" - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/project" "github.com/wailsapp/wails/v2/internal/shell" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // BaseBuilder is the common builder struct @@ -305,7 +305,7 @@ func (b *BaseBuilder) NpmRunWithEnvironment(projectDir, buildTarget string, verb } // BuildFrontend executes the `npm build` command for the frontend directory -func (b *BaseBuilder) BuildFrontend(outputLogger *logger.Logger) error { +func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error { verbose := false frontendDir := filepath.Join(b.projectData.Path, "frontend") @@ -313,10 +313,10 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *logger.Logger) error { // Check there is an 'InstallCommand' provided in wails.json if b.projectData.InstallCommand == "" { // No - don't install - outputLogger.Writeln(" - No Install command. Skipping.") + outputLogger.Println(" - No Install command. Skipping.") } else { // Do install if needed - outputLogger.Writeln(" - Installing dependencies...") + outputLogger.Println(" - Installing dependencies...") if err := b.NpmInstallUsingCommand(frontendDir, b.projectData.InstallCommand); err != nil { return err } @@ -324,12 +324,12 @@ func (b *BaseBuilder) BuildFrontend(outputLogger *logger.Logger) error { // Check if there is a build command if b.projectData.BuildCommand == "" { - outputLogger.Writeln(" - No Build command. Skipping.") + outputLogger.Println(" - No Build command. Skipping.") // No - ignore return nil } - outputLogger.Writeln(" - Compiling Frontend Project") + outputLogger.Println(" - Compiling Frontend Project") cmd := strings.Split(b.projectData.BuildCommand, " ") stdout, stderr, err := shell.RunCommand(frontendDir, cmd[0], cmd[1:]...) if verbose || err != nil { diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index c516cefd6..e80008c29 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -6,8 +6,8 @@ import ( "runtime" "github.com/leaanthony/slicer" - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/project" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // Mode is the type used to indicate the build modes @@ -24,16 +24,16 @@ var modeMap = []string{"Debug", "Production"} // Options contains all the build options as well as the project data type Options struct { - LDFlags string // Optional flags to pass to linker - Logger *logger.Logger // All output to the logger - OutputType string // EG: desktop, server.... - Mode Mode // release or debug - ProjectData *project.Project // The project data - Pack bool // Create a package for the app after building - Platform string // The platform to build for - Compiler string // The compiler command to use - IgnoreFrontend bool // Indicates if the frontend does not need building - OutputFile string // Override the output filename + LDFlags string // Optional flags to pass to linker + Logger *clilogger.CLILogger // All output to the logger + OutputType string // EG: desktop, server.... + Mode Mode // release or debug + ProjectData *project.Project // The project data + Pack bool // Create a package for the app after building + Platform string // The platform to build for + Compiler string // The compiler command to use + IgnoreFrontend bool // Indicates if the frontend does not need building + OutputFile string // Override the output filename } // GetModeAsString returns the current mode as a string @@ -47,11 +47,6 @@ func Build(options *Options) (string, error) { // Extract logger outputLogger := options.Logger - // Create a default logger if it doesn't exist - if outputLogger == nil { - outputLogger = logger.New() - } - // Get working directory cwd, err := os.Getwd() if err != nil { @@ -95,7 +90,7 @@ func Build(options *Options) (string, error) { builder.SetProjectData(projectData) if !options.IgnoreFrontend { - outputLogger.Writeln(" - Building Wails Frontend") + outputLogger.Println(" - Building Wails Frontend") err = builder.BuildFrontend(outputLogger) if err != nil { return "", err @@ -103,7 +98,7 @@ func Build(options *Options) (string, error) { } // Build the base assets - outputLogger.Writeln(" - Compiling Assets") + outputLogger.Println(" - Compiling Assets") err = builder.BuildRuntime(options) if err != nil { return "", err @@ -114,16 +109,16 @@ func Build(options *Options) (string, error) { } // Compile the application - outputLogger.Write(" - Compiling Application in " + GetModeAsString(options.Mode) + " mode...") + outputLogger.Print(" - Compiling Application in " + GetModeAsString(options.Mode) + " mode...") err = builder.CompileProject(options) if err != nil { return "", err } - outputLogger.Writeln("done.") + outputLogger.Println("done.") // Do we need to pack the app? if options.Pack { - outputLogger.Writeln(" - Packaging Application") + outputLogger.Println(" - Packaging Application") // TODO: Allow cross platform build err = packageProject(options, runtime.GOOS) diff --git a/v2/pkg/commands/build/builder.go b/v2/pkg/commands/build/builder.go index 15b5f08f6..9bbf79ed8 100644 --- a/v2/pkg/commands/build/builder.go +++ b/v2/pkg/commands/build/builder.go @@ -1,15 +1,15 @@ package build import ( - "github.com/wailsapp/wails/v2/internal/logger" "github.com/wailsapp/wails/v2/internal/project" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // Builder defines a builder that can build Wails applications type Builder interface { SetProjectData(projectData *project.Project) BuildAssets(*Options) error - BuildFrontend(*logger.Logger) error + BuildFrontend(*clilogger.CLILogger) error BuildRuntime(*Options) error CompileProject(*Options) error CleanUp() diff --git a/v2/pkg/commands/build/desktop.go b/v2/pkg/commands/build/desktop.go index 897acbe73..3176f76cc 100644 --- a/v2/pkg/commands/build/desktop.go +++ b/v2/pkg/commands/build/desktop.go @@ -7,7 +7,7 @@ import ( "github.com/wailsapp/wails/v2/internal/fs" "github.com/wailsapp/wails/v2/internal/html" - "github.com/wailsapp/wails/v2/internal/logger" + "github.com/wailsapp/wails/v2/pkg/clilogger" ) // DesktopBuilder builds applications for the desktop @@ -47,10 +47,10 @@ func (d *DesktopBuilder) BuildAssets(options *Options) error { } // BuildBaseAssets builds the assets for the desktop application -func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, outputLogger *logger.Logger) error { +func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, outputLogger *clilogger.CLILogger) error { var err error - outputLogger.Write(" - Embedding Assets...") + outputLogger.Print(" - Embedding Assets...") // Get target asset directory assetDir := fs.RelativePath("../../../internal/ffenestri") @@ -68,7 +68,7 @@ func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, outputLogger return err } - outputLogger.Writeln("done.") + outputLogger.Println("done.") return nil } @@ -101,7 +101,7 @@ func (d *DesktopBuilder) BuildRuntime(options *Options) error { return err } - outputLogger.Write(" - Embedding Runtime...") + outputLogger.Print(" - Embedding Runtime...") envvars := []string{"WAILSPLATFORM=" + options.Platform} if err := d.NpmRunWithEnvironment(sourceDir, "build:desktop", false, envvars); err != nil { return err @@ -112,7 +112,7 @@ func (d *DesktopBuilder) BuildRuntime(options *Options) error { if err != nil { return err } - outputLogger.Writeln("done.") + outputLogger.Println("done.") // Convert to C structure runtimeC := ` diff --git a/v2/pkg/commands/build/server.go b/v2/pkg/commands/build/server.go index 3b0245469..12a0ae2d2 100644 --- a/v2/pkg/commands/build/server.go +++ b/v2/pkg/commands/build/server.go @@ -99,13 +99,13 @@ func (s *ServerBuilder) BuildRuntime(options *Options) error { return err } - options.Logger.Write(" - Embedding Runtime...") + options.Logger.Print(" - Embedding Runtime...") envvars := []string{"WAILSPLATFORM=" + options.Platform} var err error if err = s.NpmRunWithEnvironment(sourceDir, "build:server", false, envvars); err != nil { return err } - options.Logger.Writeln("done.") + options.Logger.Println("done.") return nil }