Skip to content

Commit

Permalink
feat: add SetLogLevel functions
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Dec 12, 2024
1 parent 6c39f47 commit c3c93f2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import (
"unsafe"
)

type LogLevel C.PJ_LOG_LEVEL

const (
LogLevelNone LogLevel = C.PJ_LOG_NONE
LogLevelError LogLevel = C.PJ_LOG_ERROR
LogLevelDebug LogLevel = C.PJ_LOG_DEBUG
LogLevelTrace LogLevel = C.PJ_LOG_TRACE
LogLevelTell LogLevel = C.PJ_LOG_TELL
)

var defaultContext = &Context{}

func init() {
Expand Down Expand Up @@ -43,6 +53,13 @@ func (c *Context) Destroy() {
}
}

// SetLogLevel sets the log level.
func (c *Context) SetLogLevel(logLevel LogLevel) {
c.Lock()
defer c.Unlock()
C.proj_log_level(c.pjContext, C.PJ_LOG_LEVEL(logLevel))
}

// SetSearchPaths sets the paths PROJ should be exploring to find the PROJ Data files.
func (c *Context) SetSearchPaths(paths []string) {
c.Lock()
Expand Down Expand Up @@ -171,6 +188,11 @@ func (c *Context) newPJ(cPJ *C.PJ) (*PJ, error) {
return pj, nil
}

// SetLogLevel sets the log level for the default context.
func SetLogLevel(logLevel LogLevel) {
defaultContext.SetLogLevel(logLevel)
}

// New returns a PJ with the given definition.
func New(definition string) (*PJ, error) {
return defaultContext.New(definition)
Expand Down

0 comments on commit c3c93f2

Please sign in to comment.