Aego Русский

aego/log

Build messages with + and string(x). None of the functions stops the script; Error is for problems the script can recover from. Debug messages are hidden in the editor's Console unless it runs with -debug; the Run output below shows every level.

On this page

Example

package demo

import "aego/log"

script Health {
    @export var Max int = 3

    var hp int
    var frames int

    func Ready() {
        hp = Max
        log.Info(node.Name() + " starts with " + string(hp) + " hp")
        log.Debug("Debug lines are hidden in the editor unless it runs with -debug")
    }

    func Update(dt float) {
        frames++
        if frames % 30 != 0 || hp == 0 {
            return
        }
        hp--
        if hp == 0 {
            log.Error("died on frame " + string(frames))
        } else if hp == 1 {
            log.Warn("one hit left")
        } else {
            log.Info("hit, " + string(hp) + " hp left")
        }
    }
}

Functions

Debug(msg string)Writes a message to the Console. Debug messages are hidden unless the editor runs with -debug.
Error(msg string)Writes an error to the Console. It does not stop the script; use it for problems you can recover from.
Info(msg string)Writes a message to the Console.
Warn(msg string)Writes a warning to the Console.

Debug function

func Debug(msg string)

Writes a message to the Console. Debug messages are hidden unless the editor runs with -debug.

Example

log.Debug("state " + string(int(state)))

Error function

func Error(msg string)

Writes an error to the Console. It does not stop the script; use it for problems you can recover from.

Example

log.Error("spawn point missing")

Info function

func Info(msg string)

Writes a message to the Console.

Example

log.Info("ready " + node.Name())

Warn function

func Warn(msg string)

Writes a warning to the Console.

Example

log.Warn("Target is not set")