mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Add console javascript object for backwards compatibility (#4944)
This commit is contained in:
26
pkg/javascript/console.go
Normal file
26
pkg/javascript/console.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package javascript
|
||||
|
||||
import "fmt"
|
||||
|
||||
type console struct {
|
||||
Log
|
||||
}
|
||||
|
||||
func (c *console) AddToVM(globalName string, vm *VM) error {
|
||||
console := vm.NewObject()
|
||||
if err := SetAll(console,
|
||||
ObjectValueDef{"log", c.logInfo},
|
||||
ObjectValueDef{"error", c.logError},
|
||||
ObjectValueDef{"warn", c.logWarn},
|
||||
ObjectValueDef{"info", c.logInfo},
|
||||
ObjectValueDef{"debug", c.logDebug},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := vm.Set(globalName, console); err != nil {
|
||||
return fmt.Errorf("unable to set console: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user