Skip to content

Commit

Permalink
Merge pull request #5 from oderwat/setloglevel
Browse files Browse the repository at this point in the history
Simple extension to set the log level for exiv2
  • Loading branch information
antonsergeyev authored May 27, 2022
2 parents 9a61873 + b212db0 commit 33c2dd0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions exiv.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ func OpenBytes(input []byte) (*Image, error) {
return makeImage(cimg, bytesArrayPtr), nil
}

type LogMsgLevel int

const (
LogMsgDebug LogMsgLevel = 0
LogMsgInfo = 1
LogMsgWarn = 2
LogMsgError = 3
LogMsgMute = 4
)

// SetLogMsgLevel Set the log level (outputs to stderr)
func SetLogMsgLevel(level LogMsgLevel) {
C.exiv2_log_msg_set_level(C.int(level))
}

// ReadMetadata reads the metadata of an Image
func (i *Image) ReadMetadata() error {
var cerr *C.Exiv2Error
Expand Down
9 changes: 9 additions & 0 deletions helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ const char* exiv2_exif_datum_to_string(const Exiv2ExifDatum *datum)

DEFINE_FREE_FUNCTION(exiv2_exif_datum, Exiv2ExifDatum*);

// LOG LEVEL

void
exiv2_log_msg_set_level(const int level)
{
Exiv2::LogMsg::Level cpplevel = static_cast<Exiv2::LogMsg::Level>(level);
Exiv2::LogMsg::setLevel(cpplevel);
}

// ERRORS

int
Expand Down
2 changes: 2 additions & 0 deletions helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Exiv2ExifDatum* exiv2_exif_datum_iterator_next(Exiv2ExifDatumIterator *iter);
const unsigned char* exiv2_image_icc_profile(Exiv2Image *img);
long exiv2_image_icc_profile_size(Exiv2Image *img);

void exiv2_log_msg_set_level(const int level);

int exiv2_error_code(const Exiv2Error *e);
const char *exiv2_error_what(const Exiv2Error *e);
void exiv2_error_free(Exiv2Error *e);
Expand Down

0 comments on commit 33c2dd0

Please sign in to comment.