Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string representation to log level #49

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package astiav
/*
extern void goAstiavLogCallback(int level, char* fmt, char* msg, char* parent);

extern const char *get_level_str(int level);

static inline void astiavLogCallback(void *avcl, int level, const char *fmt, va_list vl)
{
if (level > av_log_get_level()) return;
Expand Down Expand Up @@ -49,6 +51,10 @@ const (
LogLevelDebug = LogLevel(C.AV_LOG_DEBUG)
)

func (l LogLevel) String() string {
return C.GoString(C.get_level_str(C.int(l)))
}

func SetLogLevel(l LogLevel) {
C.av_log_set_level(C.int(l))
}
Expand Down
3 changes: 3 additions & 0 deletions log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func TestLog(t *testing.T) {
msg: msg,
})
})

require.Equal(t, "error", astiav.LogLevelError.String())

astiav.SetLogLevel(astiav.LogLevelWarning)
astiav.Log(astiav.LogLevelInfo, "info")
astiav.Log(astiav.LogLevelWarning, "warning")
Expand Down
Loading