[pkg-opensc-commit] [opensc] 30/50: oberthur: use short form of debug message calls

Eric Dorland eric at moszumanska.debian.org
Sat May 28 03:35:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit e9786bfb345f9907ae1007f80d94f6eb3f773d59
Author: Viktor Tarasov <viktor.tarasov at gmail.com>
Date:   Thu Apr 28 11:01:54 2016 +0200

    oberthur: use short form of debug message calls
---
 src/libopensc/card-oberthur.c | 524 +++++++++++++++++++++---------------------
 1 file changed, 260 insertions(+), 264 deletions(-)

diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c
index 6326d46..52dfb4b 100644
--- a/src/libopensc/card-oberthur.c
+++ b/src/libopensc/card-oberthur.c
@@ -170,7 +170,7 @@ auth_select_aid(struct sc_card *card)
 	apdu.resp = apdu_resp;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	/* Get smart card serial number */
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x9F, 0x7F);
@@ -180,14 +180,14 @@ auth_select_aid(struct sc_card *card)
 	apdu.resp = apdu_resp;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	card->serialnr.len = 4;
 	memcpy(card->serialnr.value, apdu.resp+15, 4);
 
 	for (ii=0, data->sn = 0; ii < 4; ii++)
 		data->sn += (long int)(*(apdu.resp + 15 + ii)) << (3-ii)*8;
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "serial number %li/0x%lX\n", data->sn, data->sn);
+	sc_log(card->ctx, "serial number %li/0x%lX", data->sn, data->sn);
 
 	memset(&tmp_path, 0, sizeof(struct sc_path));
 	tmp_path.type = SC_PATH_TYPE_DF_NAME;
@@ -195,13 +195,11 @@ auth_select_aid(struct sc_card *card)
 	tmp_path.len = lenAidAuthentIC_V5;
 
 	rv = iso_ops->select_file(card, &tmp_path, NULL);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n", rv);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select parent failed");
+	LOG_TEST_RET(card->ctx, rv, "select parent failed");
 
 	sc_format_path("3F00", &tmp_path);
 	rv = iso_ops->select_file(card, &tmp_path, &auth_current_df);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n", rv);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select parent failed");
+	LOG_TEST_RET(card->ctx, rv, "select parent failed");
 
 	sc_format_path("3F00", &card->cache.current_path);
 	sc_file_dup(&auth_current_ef, auth_current_df);
@@ -210,8 +208,7 @@ auth_select_aid(struct sc_card *card)
 	data->aid_len = lenAidAuthentIC_V5;
 	card->name = nameAidAuthentIC_V5;
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "return %i\n", rv);
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -235,7 +232,7 @@ auth_init(struct sc_card *card)
 
 	data = calloc(1, sizeof(struct auth_private_data));
 	if (!data)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
 
 	card->cla = 0x00;
 	card->drv_data = data;
@@ -244,8 +241,8 @@ auth_init(struct sc_card *card)
 	card->caps |= SC_CARD_CAP_USE_FCI_AC;
 
 	if (auth_select_aid(card))   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize %s\n", card->name);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD, "Failed to initialize");
+		sc_log(card->ctx, "Failed to initialize %s", card->name);
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_CARD, "Failed to initialize");
 	}
 
 	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
@@ -259,7 +256,7 @@ auth_init(struct sc_card *card)
 	sc_format_path("3F00", &path);
 	rv = auth_select_file(card, &path, NULL);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -268,7 +265,7 @@ add_acl_entry(struct sc_card *card, struct sc_file *file, unsigned int op,
 		unsigned char acl_byte)
 {
 	if ((acl_byte & 0xE0) == 0x60)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called; op 0x%X; SC_AC_PRO; ref 0x%X\n", op, acl_byte);
+		sc_log(card->ctx, "called; op 0x%X; SC_AC_PRO; ref 0x%X", op, acl_byte);
 		sc_file_add_acl_entry(file, op, SC_AC_PRO, acl_byte);
 		return;
 	}
@@ -334,22 +331,22 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 	unsigned char type, attr[SC_OBERTHUR_MAX_ATTR_SIZE];
 	int attr_len = sizeof(attr);
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	attr_len = sizeof(attr);
 	if (tlv_get(buf, buflen, 0x82, attr, &attr_len))
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 	type = attr[0];
 
 	attr_len = sizeof(attr);
 	if (tlv_get(buf, buflen, 0x83, attr, &attr_len))
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 	file->id = attr[0]*0x100 + attr[1];
 
 	attr_len = sizeof(attr);
 	if (tlv_get(buf, buflen, type==0x01 ? 0x80 : 0x85, attr, &attr_len))
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 	if (attr_len<2 && type != 0x04)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 
 	switch (type) {
 	case 0x01:
@@ -363,9 +360,9 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 		file->size = attr[0];
 		attr_len = sizeof(attr);
 		if (tlv_get(buf, buflen, 0x82, attr, &attr_len))
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 		if (attr_len!=5)
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 		file->record_length = attr[2]*0x100+attr[3];
 		file->record_count = attr[4];
 		break;
@@ -387,8 +384,8 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 		else if (file->size==2048)
 			file->size = PUBKEY_2048_ASN1_SIZE;
 		else   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Not supported public key size: %i\n", file->size);
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+			sc_log(card->ctx, "Not supported public key size: %i", file->size);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 		}
 		break;
 	case 0x14:
@@ -400,17 +397,17 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 		file->type = SC_FILE_TYPE_DF;
 		file->size = attr[0];
 		if (SC_SUCCESS != sc_file_set_type_attr(file,attr,attr_len))
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 		break;
 	default:
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 	}
 
 	attr_len = sizeof(attr);
 	if (tlv_get(buf, buflen, 0x86, attr, &attr_len))
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 	if (attr_len<8)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_UNKNOWN_DATA_RECEIVED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
 
 	if (file->type == SC_FILE_TYPE_DF) {
 		add_acl_entry(card, file, SC_AC_OP_CREATE, attr[0]);
@@ -420,7 +417,7 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 		add_acl_entry(card, file, SC_AC_OP_PIN_DEFINE, attr[4]);
 		add_acl_entry(card, file, SC_AC_OP_PIN_CHANGE, attr[5]);
 		add_acl_entry(card, file, SC_AC_OP_PIN_RESET, attr[6]);
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_FILE_TYPE_DF:CRYPTO %X\n", attr[1]);
+		sc_log(card->ctx, "SC_FILE_TYPE_DF:CRYPTO %X", attr[1]);
 	}
 	else if (file->type == SC_FILE_TYPE_INTERNAL_EF)  { /* EF */
 		switch (file->ef_structure) {
@@ -467,7 +464,7 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
 	file->status = SC_FILE_STATUS_ACTIVATED;
 	file->magic = SC_FILE_MAGIC;
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
 }
 
 
@@ -480,17 +477,17 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 	size_t offs, ii;
 	int rv;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	assert(card != NULL && in_path != NULL);
 
 	memcpy(&path, in_path, sizeof(struct sc_path));
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "in_path; type=%d, path=%s, out %p\n",
+	sc_log(card->ctx, "in_path; type=%d, path=%s, out %p",
 			in_path->type, sc_print_path(in_path), file_out);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "current path; type=%d, path=%s\n",
+	sc_log(card->ctx, "current path; type=%d, path=%s",
 			auth_current_df->path.type, sc_print_path(&auth_current_df->path));
 	if (auth_current_ef)
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "current file; type=%d, path=%s\n",
+		sc_log(card->ctx, "current file; type=%d, path=%s",
 				auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
 
 	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID)   {
@@ -499,7 +496,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 		auth_current_ef = NULL;
 
 		rv = iso_ops->select_file(card, &path, &tmp_file);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select file failed");
+		LOG_TEST_RET(card->ctx, rv, "select file failed");
 		if (!tmp_file)
 			return SC_ERROR_OBJECT_NOT_FOUND;
 
@@ -538,7 +535,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 				sc_file_free(auth_current_ef);
 			auth_current_ef = NULL;
 		}
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select file failed");
+		LOG_TEST_RET(card->ctx, rv, "select file failed");
 	}
 	else   {
 		for (offs = 0; offs < path.len && offs < auth_current_df->path.len; offs += 2)
@@ -546,11 +543,11 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 					path.value[offs + 1] != auth_current_df->path.value[offs + 1])
 				break;
 
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "offs %i\n", offs);
+		sc_log(card->ctx, "offs %i", offs);
 		if (offs && offs < auth_current_df->path.len)   {
 			size_t deep = auth_current_df->path.len - offs;
 
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "deep %i\n", deep);
+			sc_log(card->ctx, "deep %i", deep);
 			for (ii=0; ii<deep; ii+=2)   {
 				struct sc_path tmp_path;
 
@@ -558,7 +555,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 				tmp_path.type = SC_PATH_TYPE_PARENT;
 
 				rv = auth_select_file (card, &tmp_path, file_out);
-				SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select file failed");
+				LOG_TEST_RET(card->ctx, rv, "select file failed");
 			}
 		}
 
@@ -573,7 +570,7 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 				memcpy(tmp_path.value, path.value + offs + ii, 2);
 
 				rv = auth_select_file(card, &tmp_path, file_out);
-				SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select file failed");
+				LOG_TEST_RET(card->ctx, rv, "select file failed");
 			}
 		}
 		else if (path.len - offs == 0 && file_out)  {
@@ -582,11 +579,11 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path,
 			else  if (auth_current_ef)
 				sc_file_dup(file_out, auth_current_ef);
 			else
-				SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL, "No current EF");
+				LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "No current EF");
 		}
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0);
+	LOG_FUNC_RETURN(card->ctx, 0);
 }
 
 
@@ -597,7 +594,7 @@ auth_list_files(struct sc_card *card, unsigned char *buf, size_t buflen)
 	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
 	int rv;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x34, 0, 0);
 	apdu.cla = 0x80;
 	apdu.le = 0x40;
@@ -605,18 +602,18 @@ auth_list_files(struct sc_card *card, unsigned char *buf, size_t buflen)
 	apdu.resp = rbuf;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	if (apdu.resplen == 0x100 && rbuf[0]==0 && rbuf[1]==0)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0);
+		LOG_FUNC_RETURN(card->ctx, 0);
 
 	buflen = buflen < apdu.resplen ? buflen : apdu.resplen;
 	memcpy(buf, rbuf, buflen);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, buflen);
+	LOG_FUNC_RETURN(card->ctx, buflen);
 }
 
 
@@ -628,18 +625,17 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 	int rv;
 	char pbuf[SC_MAX_PATH_STRING_SIZE];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	rv = sc_path_print(pbuf, sizeof(pbuf), path);
 	if (rv != SC_SUCCESS)
 		pbuf[0] = '\0';
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
-		"path; type=%d, path=%s\n", path->type, pbuf);
+	sc_log(card->ctx, "path; type=%d, path=%s", path->type, pbuf);
 
 	if (path->len < 2)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid path length\n");
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		sc_log(card->ctx, "Invalid path length");
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 	}
 
 	if (path->len > 2)   {
@@ -648,7 +644,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 		parent.len -= 2;
 		parent.type = SC_PATH_TYPE_PATH;
 		rv = auth_select_file(card, &parent, NULL);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select parent failed ");
+		LOG_TEST_RET(card->ctx, rv, "select parent failed ");
 	}
 
 	sbuf[0] = path->value[path->len - 2];
@@ -656,7 +652,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 
 	if (memcmp(sbuf,"\x00\x00",2)==0 || (memcmp(sbuf,"\xFF\xFF",2)==0) ||
 			memcmp(sbuf,"\x3F\xFF",2)==0)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x02, 0x00);
 	apdu.lc = 2;
@@ -664,7 +660,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 	apdu.data = sbuf;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	if (apdu.sw1==0x6A && apdu.sw2==0x82)   {
 		/* Clean up tDF contents.*/
 		struct sc_path tmp_path;
@@ -676,10 +672,10 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 		memcpy(tmp_path.value, sbuf, 2);
 		tmp_path.len = 2;
 		rv = auth_select_file(card, &tmp_path, NULL);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select DF failed");
+		LOG_TEST_RET(card->ctx, rv, "select DF failed");
 
 		len = auth_list_files(card, lbuf, sizeof(lbuf));
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, len, "list DF failed");
+		LOG_TEST_RET(card->ctx, len, "list DF failed");
 
 		for (ii=0; ii<len/2; ii++)   {
 			struct sc_path tmp_path_x;
@@ -691,21 +687,21 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path)
 			tmp_path_x.len = 2;
 
 			rv = auth_delete_file(card, &tmp_path_x);
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "delete failed");
+			LOG_TEST_RET(card->ctx, rv, "delete failed");
 		}
 
 		tmp_path.type = SC_PATH_TYPE_PARENT;
 		rv = auth_select_file(card, &tmp_path, NULL);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select parent failed");
+		LOG_TEST_RET(card->ctx, rv, "select parent failed");
 
 		apdu.p1 = 1;
 		rv = sc_transmit_apdu(card, &apdu);
 	}
 
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -721,25 +717,25 @@ acl_to_ac_byte(struct sc_card *card, const struct sc_acl_entry *e)
 
 	switch (e->method) {
 	case SC_AC_NONE:
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0);
+		LOG_FUNC_RETURN(card->ctx, 0);
 
 	case SC_AC_CHV:
 		if (key_ref > 0 && key_ref < 6)
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, (0x20 | key_ref));
+			LOG_FUNC_RETURN(card->ctx, (0x20 | key_ref));
 		else
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 
 	case SC_AC_PRO:
 		if (((key_ref & 0xE0) != 0x60) || ((key_ref & 0x18) == 0))
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 		else
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, key_ref);
+			LOG_FUNC_RETURN(card->ctx, key_ref);
 
 	case SC_AC_NEVER:
 		return 0xff;
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+	LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 }
 
 
@@ -752,12 +748,12 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 	unsigned char *p = buf;
 	unsigned char  ops[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "id %04X; size %i; type 0x%X/0x%X\n",
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "id %04X; size %i; type 0x%X/0x%X",
 			file->id, file->size, file->type, file->ef_structure);
 
 	if (*buflen < 0x18)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 
 	p[0] = 0x62, p[1] = 0x16;
 	p[2] = 0x82, p[3] = 0x02;
@@ -805,8 +801,8 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 		rv = SC_ERROR_INVALID_ARGUMENTS;
 
 	if (rv)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid EF structure 0x%X/0x%X\n", file->type, file->ef_structure);
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+		sc_log(card->ctx, "Invalid EF structure 0x%X/0x%X", file->type, file->ef_structure);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 	}
 
 	p[6] = 0x83;
@@ -824,7 +820,7 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 	}
 	else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
 			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "ef %s\n","SC_FILE_EF_RSA_PUBLIC");
+		sc_log(card->ctx, "ef %s","SC_FILE_EF_RSA_PUBLIC");
 		if (file->size == PUBKEY_512_ASN1_SIZE || file->size == 512)
 			size = 512;
 		else if (file->size == PUBKEY_1024_ASN1_SIZE || file->size == 1024)
@@ -832,8 +828,8 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 		else if (file->size == PUBKEY_2048_ASN1_SIZE || file->size == 2048)
 			size = 2048;
 		else   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "incorrect RSA size %X\n", file->size);
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+			sc_log(card->ctx, "incorrect RSA size %X", file->size);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 		}
 	}
 	else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
@@ -845,8 +841,8 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 		else if (file->size == 24 || file->size == 192)
 			size = 192;
 		else   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "incorrect DES size %i\n", file->size);
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+			sc_log(card->ctx, "incorrect DES size %i", file->size);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 		}
 	}
 
@@ -867,14 +863,14 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 	}
 	else if (file->type == SC_FILE_TYPE_WORKING_EF)   {
 		if (file->ef_structure == SC_FILE_EF_TRANSPARENT)   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_FILE_EF_TRANSPARENT\n");
+			sc_log(card->ctx, "SC_FILE_EF_TRANSPARENT");
 			ops[0] = SC_AC_OP_WRITE;
 			ops[1] = SC_AC_OP_UPDATE;
 			ops[2] = SC_AC_OP_READ;
 			ops[3] = SC_AC_OP_ERASE;
 		}
 		else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE)  {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_FILE_EF_LINEAR_VARIABLE\n");
+			sc_log(card->ctx, "SC_FILE_EF_LINEAR_VARIABLE");
 			ops[0] = SC_AC_OP_WRITE;
 			ops[1] = SC_AC_OP_UPDATE;
 			ops[2] = SC_AC_OP_READ;
@@ -883,7 +879,7 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 	}
 	else   if (file->type == SC_FILE_TYPE_INTERNAL_EF)   {
 		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES)  {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF_DES\n");
+			sc_log(card->ctx, "EF_DES");
 			ops[0] = SC_AC_OP_UPDATE;
 			ops[1] = SC_AC_OP_PSO_DECRYPT;
 			ops[2] = SC_AC_OP_PSO_ENCRYPT;
@@ -893,14 +889,14 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
 		}
 		else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)  {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF_RSA_PUBLIC\n");
+			sc_log(card->ctx, "EF_RSA_PUBLIC");
 			ops[0] = SC_AC_OP_UPDATE;
 			ops[2] = SC_AC_OP_PSO_ENCRYPT;
 			ops[4] = SC_AC_OP_PSO_VERIFY_SIGNATURE;
 			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
 		}
 		else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT)  {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF_RSA_PRIVATE\n");
+			sc_log(card->ctx, "EF_RSA_PRIVATE");
 			ops[0] = SC_AC_OP_UPDATE;
 			ops[1] = SC_AC_OP_PSO_DECRYPT;
 			ops[3] = SC_AC_OP_PSO_COMPUTE_SIGNATURE;
@@ -916,13 +912,13 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
 			continue;
 		entry = sc_file_get_acl_entry(file, ops[ii]);
 		rv = acl_to_ac_byte(card,entry);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Invalid ACL");
+		LOG_TEST_RET(card->ctx, rv, "Invalid ACL");
 		p[16+ii] = rv;
 	}
 
 	*buflen = 0x18;
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
 }
 
 
@@ -936,19 +932,19 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
 	size_t sendlen = sizeof(sbuf);
 	char pbuf[SC_MAX_PATH_STRING_SIZE];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	rv = sc_path_print(pbuf, sizeof(pbuf), &file->path);
 	if (rv != SC_SUCCESS)
 		pbuf[0] = '\0';
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, " create path=%s\n", pbuf);
+	sc_log(card->ctx, " create path=%s", pbuf);
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
-		"id %04X; size %i; type 0x%X; ef 0x%X\n",
+	sc_log(card->ctx,
+		"id %04X; size %i; type 0x%X; ef 0x%X",
 		file->id, file->size, file->type, file->ef_structure);
 
 	if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 	rv = sc_path_print(pbuf, sizeof(pbuf), &card->cache.current_path);
 	if (rv != SC_SUCCESS)
@@ -960,13 +956,13 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
 			path.len -= 2;
 
 		if (auth_select_file(card, &path, NULL))   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cannot select parent DF.\n");
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+			sc_log(card->ctx, "Cannot select parent DF.");
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 		}
 	}
 
 	rv = encode_file_structure_V5(card, file, sbuf, &sendlen);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "File structure encoding failed");
+	LOG_TEST_RET(card->ctx, rv, "File structure encoding failed");
 
 	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
 		rec_nr = file->record_count;
@@ -979,9 +975,9 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
 	apdu.lc = sendlen;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	/* select created DF. */
 	if (file->type == SC_FILE_TYPE_DF)   {
@@ -994,14 +990,14 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
 		tmp_path.value[1] = file->id & 0xFF;
 		tmp_path.len = 2;
 		rv = auth_select_file(card, &tmp_path, &df_file);
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i", rv);
+		sc_log(card->ctx, "rv %i", rv);
 	}
 
 	if (auth_current_ef)
 		sc_file_free(auth_current_ef);
 	sc_file_dup(&auth_current_ef, file);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1022,20 +1018,20 @@ auth_set_security_env(struct sc_card *card,
 		0x87, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 	};
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "op %i; path %s; key_ref 0x%X; algos 0x%X; flags 0x%X\n",
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "op %i; path %s; key_ref 0x%X; algos 0x%X; flags 0x%X",
 			env->operation, sc_print_path(&env->file_ref), env->key_ref[0],
 			env->algorithm_flags, env->flags);
 
 	memset(auth_senv, 0, sizeof(struct auth_senv));
 
 	if (!(env->flags & SC_SEC_ENV_FILE_REF_PRESENT))
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL, "Key file is not selected.");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "Key file is not selected.");
 
 	switch (env->algorithm)   {
 	case SC_ALGORITHM_DES:
 	case SC_ALGORITHM_3DES:
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "algo SC_ALGORITHM_xDES: ref %X, flags %X\n",
+		sc_log(card->ctx, "algo SC_ALGORITHM_xDES: ref %X, flags %X",
 				env->algorithm_ref, env->flags);
 
 		if (env->operation == SC_SEC_OPERATION_DECIPHER)   {
@@ -1045,20 +1041,20 @@ auth_set_security_env(struct sc_card *card,
 			apdu.datalen = 3;
 		}
 		else {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto operation: %X\n", env->operation);
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Invalid crypto operation");
+			sc_log(card->ctx, "Invalid crypto operation: %X", env->operation);
+			LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Invalid crypto operation");
 		}
 
 		break;
 	case SC_ALGORITHM_RSA:
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "algo SC_ALGORITHM_RSA\n");
+		sc_log(card->ctx, "algo SC_ALGORITHM_RSA");
 		if (env->algorithm_flags & SC_ALGORITHM_RSA_HASHES) {
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "No support for hashes.");
+			LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "No support for hashes.");
 		}
 
 		if (pads & (~supported_pads))   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No support for PAD %X\n",pads);
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "No padding support.");
+			sc_log(card->ctx, "No support for PAD %X",pads);
+			LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "No padding support.");
 		}
 
 		if (env->operation == SC_SEC_OPERATION_SIGN)   {
@@ -1078,23 +1074,23 @@ auth_set_security_env(struct sc_card *card,
 			apdu.data = rsa_sbuf;
 		}
 		else {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto operation: %X\n", env->operation);
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED);
+			sc_log(card->ctx, "Invalid crypto operation: %X", env->operation);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
 		}
 
 		break;
 	default:
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Invalid crypto algorithm supplied");
+		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Invalid crypto algorithm supplied");
 	}
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	auth_senv->algorithm = env->algorithm;
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1117,12 +1113,12 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
 		return SC_ERROR_INVALID_ARGUMENTS;
 	}
 	else if (ilen > 96)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Illegal input length %d\n", ilen);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Illegal input length");
+		sc_log(card->ctx, "Illegal input length %d", ilen);
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Illegal input length");
 	}
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "inlen %i, outlen %i\n", ilen, olen);
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "inlen %i, outlen %i", ilen, olen);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A);
 	apdu.datalen = ilen;
@@ -1133,19 +1129,19 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
 	apdu.resplen = olen;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Compute signature failed");
+	LOG_TEST_RET(card->ctx, rv, "Compute signature failed");
 
 	if (apdu.resplen > olen)   {
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Compute signature failed: invalide response length %i\n",
+		sc_log(card->ctx, "Compute signature failed: invalide response length %i",
 				apdu.resplen);
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
 	}
 
 	memcpy(out, apdu.resp, apdu.resplen);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, apdu.resplen);
+	LOG_FUNC_RETURN(card->ctx, apdu.resplen);
 }
 
 
@@ -1157,14 +1153,14 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen,
 	unsigned char resp[SC_MAX_APDU_BUFFER_SIZE];
 	int rv, _inlen = inlen;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"crgram_len %i;  outlen %i\n", inlen, outlen);
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx,"crgram_len %i;  outlen %i", inlen, outlen);
 	if (!out || !outlen || inlen > SC_MAX_APDU_BUFFER_SIZE)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "algorithm SC_ALGORITHM_RSA\n");
+	sc_log(card->ctx, "algorithm SC_ALGORITHM_RSA");
 	if (inlen % 64)   {
 		rv = SC_ERROR_INVALID_ARGUMENTS;
 		goto done;
@@ -1181,10 +1177,10 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen,
 		apdu.le = 256;
 
 		rv = sc_transmit_apdu(card, &apdu);
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i", rv);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+		sc_log(card->ctx, "rv %i", rv);
+		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+		LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 		_inlen -= 8;
 		in += 8;
@@ -1200,11 +1196,11 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen,
 	apdu.le = _inlen;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i", rv);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	sc_log(card->ctx, "rv %i", rv);
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "rv %i", rv);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	sc_log(card->ctx, "rv %i", rv);
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	if (outlen > apdu.resplen)
 		outlen = apdu.resplen;
@@ -1213,7 +1209,7 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen,
 	rv = outlen;
 
 done:
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1221,7 +1217,7 @@ done:
 static int
 auth_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data)
 {
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NO_DEFAULT_KEY);
+	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_DEFAULT_KEY);
 }
 
 
@@ -1254,10 +1250,10 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	struct sc_path tmp_path;
 	int rv = 0;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	if (data->key_bits < 512 || data->key_bits > 2048 ||
 			(data->key_bits%0x20)!=0)   {
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Illegal key length");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Illegal key length");
 	}
 
 	sbuf[0] = (data->id_pub >> 8) & 0xFF;
@@ -1266,7 +1262,7 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	sbuf[3] = data->id_prv & 0xFF;
 	if (data->exponent != 0x10001)   {
 		rv = auth_encode_exponent(data->exponent, &sbuf[5],SC_MAX_APDU_BUFFER_SIZE-6);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot encode exponent");
+		LOG_TEST_RET(card->ctx, rv, "Cannot encode exponent");
 
 		sbuf[4] = rv;
 		rv++;
@@ -1275,7 +1271,7 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x46, 0x00, 0x00);
 	apdu.resp = calloc(1, data->key_bits/8+8);
 	if (!apdu.resp)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
 
 	apdu.resplen = data->key_bits/8+8;
 	apdu.lc = rv + 4;
@@ -1284,9 +1280,9 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	apdu.datalen = rv + 4;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	memset(&tmp_path, 0, sizeof(struct sc_path));
 	tmp_path.type = SC_PATH_TYPE_FILE_ID;
@@ -1294,17 +1290,17 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	memcpy(tmp_path.value, sbuf, 2);
 
 	rv = auth_select_file(card, &tmp_path, NULL);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "cannot select public key");
+	LOG_TEST_RET(card->ctx, rv, "cannot select public key");
 
 	rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 			1, apdu.resp, data->key_bits/8);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "auth_read_component() returned error");
+	LOG_TEST_RET(card->ctx, rv, "auth_read_component() returned error");
 
 	apdu.resplen = rv;
 
 	if (data->pubkey)   {
 		if (data->pubkey_len < apdu.resplen)
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 		memcpy(data->pubkey,apdu.resp,apdu.resplen);
 	}
@@ -1312,8 +1308,8 @@ auth_generate_key(struct sc_card *card, int use_sm,
 	data->pubkey_len = apdu.resplen;
 	free(apdu.resp);
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "resulted public key len %i\n", apdu.resplen);
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+	sc_log(card->ctx, "resulted public key len %i", apdu.resplen);
+	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
 }
 
 
@@ -1325,11 +1321,11 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a
 	unsigned char ins, p1, p2;
 	int rv, len;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	if (args->len > sizeof(sbuf) || args->len > 0x100)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "nn %i; len %i\n", args->component, args->len);
+	sc_log(card->ctx, "nn %i; len %i", args->component, args->len);
 	ins = 0xD8;
 	p1 = args->component;
 	p2 = 0x04;
@@ -1347,7 +1343,7 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a
 		EVP_CIPHER_CTX ctx;
 
 		if (args->len!=8 && args->len!=24)
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 		p2 = 0;
 		EVP_CIPHER_CTX_init(&ctx);
@@ -1357,8 +1353,8 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a
 			EVP_EncryptInit_ex(&ctx, EVP_des_ecb(), NULL, args->data, NULL);
 		rv = EVP_EncryptUpdate(&ctx, out, &outl, in, 8);
 		if (!EVP_CIPHER_CTX_cleanup(&ctx) || rv == 0) {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "OpenSSL encryption error.");
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
+			sc_log(card->ctx, "OpenSSL encryption error.");
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
 		}
 
 		sbuf[len++] = 0x03;
@@ -1385,7 +1381,7 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a
 		apdu.lc = 0x23;
 		rv = sc_transmit_apdu(card, &apdu);
 		apdu.cla &= ~0x10;
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 		sbuf[0] = args->type;
 		sbuf[1] = 0xE0;
@@ -1398,10 +1394,10 @@ auth_update_component(struct sc_card *card, struct auth_update_component_info *a
 
 	rv = sc_transmit_apdu(card, &apdu);
 	sc_mem_clear(sbuf, sizeof(sbuf));
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1410,16 +1406,16 @@ auth_update_key(struct sc_card *card, struct sc_cardctl_oberthur_updatekey_info
 {
 	int rv, ii;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	if (info->data_len != sizeof(void *) || !info->data)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 	if (info->type == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT)   {
 		struct sc_pkcs15_prkey_rsa  *rsa = (struct sc_pkcs15_prkey_rsa *)info->data;
 		struct sc_pkcs15_bignum bn[5];
 
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Import RSA CRT");
+		sc_log(card->ctx, "Import RSA CRT");
 		bn[0] = rsa->p;
 		bn[1] = rsa->q;
 		bn[2] = rsa->iqmp;
@@ -1435,7 +1431,7 @@ auth_update_key(struct sc_card *card, struct sc_cardctl_oberthur_updatekey_info
 			args.len = bn[ii].len;
 
 			rv = auth_update_component(card, &args);
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Update RSA component failed");
+			LOG_TEST_RET(card->ctx, rv, "Update RSA component failed");
 		}
 	}
 	else if (info->type == SC_CARDCTL_OBERTHUR_KEY_DES)   {
@@ -1445,7 +1441,7 @@ auth_update_key(struct sc_card *card, struct sc_cardctl_oberthur_updatekey_info
 		rv = SC_ERROR_INVALID_DATA;
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1471,7 +1467,7 @@ auth_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr)
 	case SC_CARDCTL_LIFECYCLE_SET:
 		return SC_ERROR_NOT_SUPPORTED;
 	default:
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
 	}
 }
 
@@ -1484,11 +1480,11 @@ auth_read_component(struct sc_card *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type
 	int rv;
 	unsigned char resp[256];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "num %i, outlen %i, type %i\n", num, outlen, type);
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "num %i, outlen %i, type %i", num, outlen, type);
 
 	if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB4,	num, 0x00);
 	apdu.cla |= 0x80;
@@ -1496,16 +1492,16 @@ auth_read_component(struct sc_card *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type
 	apdu.resp = resp;
 	apdu.resplen = sizeof(resp);
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
 	if (outlen < apdu.resplen)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_WRONG_LENGTH);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
 
 	memcpy(out, apdu.resp, apdu.resplen);
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, apdu.resplen);
+	LOG_FUNC_RETURN(card->ctx, apdu.resplen);
 }
 
 
@@ -1513,12 +1509,12 @@ static int
 auth_get_pin_reference (struct sc_card *card, int type, int reference, int cmd, int *out_ref)
 {
 	if (!out_ref)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 	switch (type) {
 	case SC_AC_CHV:
 		if (reference != 1 && reference != 2 && reference != 4)
-			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_PIN_REFERENCE);
+			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_PIN_REFERENCE);
 
 		*out_ref = reference;
 		if (reference == 1 || reference == 4)
@@ -1527,10 +1523,10 @@ auth_get_pin_reference (struct sc_card *card, int type, int reference, int cmd,
 		break;
 
 	default:
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
 }
 
 
@@ -1562,18 +1558,18 @@ auth_pin_verify_pinpad(struct sc_card *card, int pin_reference, int *tries_left)
 	unsigned char ffs1[0x100];
 	int rv;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	memset(ffs1, 0xFF, sizeof(ffs1));
 	memset(&pin_cmd, 0, sizeof(pin_cmd));
 
         rv = auth_pin_is_verified(card, pin_reference, tries_left);
-    	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "auth_pin_is_verified returned rv %i\n", rv);
+    	sc_log(card->ctx, "auth_pin_is_verified returned rv %i", rv);
 
 	/* Return SUCCESS without verifying if
 	 * PIN has been already verified and PIN pad has to be used. */
 	if (!rv)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+		LOG_FUNC_RETURN(card->ctx, rv);
 
 	pin_cmd.flags |= SC_PIN_CMD_NEED_PADDING;
 
@@ -1603,9 +1599,9 @@ auth_pin_verify_pinpad(struct sc_card *card, int pin_reference, int *tries_left)
 	pin_cmd.pin1.pad_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
 
 	rv = iso_drv->ops->pin_cmd(card, &pin_cmd, tries_left);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "PIN CMD 'VERIFY' with pinpad failed");
+	LOG_TEST_RET(card->ctx, rv, "PIN CMD 'VERIFY' with pinpad failed");
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1616,10 +1612,10 @@ auth_pin_verify(struct sc_card *card, unsigned int type,
 	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 	int rv;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	if (type != SC_AC_CHV)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "PIN type other then SC_AC_CHV is not supported");
+		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "PIN type other then SC_AC_CHV is not supported");
 
 	data->flags |= SC_PIN_CMD_NEED_PADDING;
 
@@ -1631,23 +1627,23 @@ auth_pin_verify(struct sc_card *card, unsigned int type,
 		data->pin_reference  |= OBERTHUR_PIN_LOCAL;
 
         rv = auth_pin_is_verified(card, data->pin_reference, tries_left);
-    	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "auth_pin_is_verified returned rv %i\n", rv);
+    	sc_log(card->ctx, "auth_pin_is_verified returned rv %i", rv);
 
 	/* Return if only PIN status has been asked. */
 	if (data->pin1.data && !data->pin1.len)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+		LOG_FUNC_RETURN(card->ctx, rv);
 
 	/* Return SUCCESS without verifying if
 	 * PIN has been already verified and PIN pad has to be used. */
 	if (!rv && !data->pin1.data && !data->pin1.len)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+		LOG_FUNC_RETURN(card->ctx, rv);
 
 	if (!data->pin1.data && !data->pin1.len)
 		rv = auth_pin_verify_pinpad(card, data->pin_reference, tries_left);
 	else
 		rv = iso_drv->ops->pin_cmd(card, data, tries_left);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1660,7 +1656,7 @@ auth_pin_is_verified(struct sc_card *card, int pin_reference, int *tries_left)
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0, pin_reference);
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	if (tries_left && apdu.sw1 == 0x63 && (apdu.sw2 & 0xF0) == 0xC0)
 		*tries_left = apdu.sw2 & 0x0F;
@@ -1688,7 +1684,7 @@ auth_pin_change_pinpad(struct sc_card *card, struct sc_pin_cmd_data *data,
 	unsigned char ffs2[0x100];
 	int rv, pin_reference;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	pin_reference = data->pin_reference & ~OBERTHUR_PIN_LOCAL;
 
@@ -1697,7 +1693,7 @@ auth_pin_change_pinpad(struct sc_card *card, struct sc_pin_cmd_data *data,
 	memset(&pin_cmd, 0, sizeof(pin_cmd));
 
 	if (data->pin1.len > OBERTHUR_AUTH_MAX_LENGTH_PIN)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "'PIN CHANGE' failed");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "'PIN CHANGE' failed");
 
 	if (data->pin1.data && data->pin1.len)
 		memcpy(ffs1, data->pin1.data, data->pin1.len);
@@ -1728,9 +1724,9 @@ auth_pin_change_pinpad(struct sc_card *card, struct sc_pin_cmd_data *data,
 	pin_cmd.pin2.data = ffs2;
 
 	rv = iso_drv->ops->pin_cmd(card, &pin_cmd, tries_left);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "PIN CMD 'VERIFY' with pinpad failed");
+	LOG_TEST_RET(card->ctx, rv, "PIN CMD 'VERIFY' with pinpad failed");
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1741,7 +1737,7 @@ auth_pin_change(struct sc_card *card, unsigned int type,
 	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 	int rv = SC_ERROR_INTERNAL;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	if (data->pin1.len && data->pin2.len)   {
 		/* Direct unblock style */
@@ -1755,18 +1751,18 @@ auth_pin_change(struct sc_card *card, unsigned int type,
 		auth_init_pin_info(card, &data->pin2, OBERTHUR_AUTH_TYPE_PIN);
 
 		rv = iso_drv->ops->pin_cmd(card, data, tries_left);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "CMD 'PIN CHANGE' failed");
+		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN CHANGE' failed");
 	}
 	else if (!data->pin1.len && !data->pin2.len)   {
 		/* Oberthur unblock style with PIN pad. */
 		rv = auth_pin_change_pinpad(card, data, tries_left);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "'PIN CHANGE' failedi: SOPIN verify with pinpad failed");
+		LOG_TEST_RET(card->ctx, rv, "'PIN CHANGE' failedi: SOPIN verify with pinpad failed");
 	}
 	else   {
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "'PIN CHANGE' failed");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "'PIN CHANGE' failed");
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1783,12 +1779,12 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
 	unsigned char ffs1[0x100];
 	int rv, rvv, local_pin_reference;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	local_pin_reference = data->pin_reference & ~OBERTHUR_PIN_LOCAL;
 
 	if (data->pin_reference !=  OBERTHUR_PIN_REFERENCE_USER)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Oberthur style 'PIN RESET' failed: invalid PIN reference");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Oberthur style 'PIN RESET' failed: invalid PIN reference");
 
 	memset(&pin_cmd, 0, sizeof(pin_cmd));
 	memset(&tmp_path, 0, sizeof(struct sc_path));
@@ -1799,20 +1795,20 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
 	memcpy(&pin_cmd.pin1, &data->pin1, sizeof(pin_cmd.pin1));
 
 	rv = auth_pin_verify(card, SC_AC_CHV, &pin_cmd, tries_left);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Oberthur style 'PIN RESET' failed: SOPIN verify error");
+	LOG_TEST_RET(card->ctx, rv, "Oberthur style 'PIN RESET' failed: SOPIN verify error");
 
 	sc_format_path("2000", &tmp_path);
 	tmp_path.type = SC_PATH_TYPE_FILE_ID;
 	rv = iso_ops->select_file(card, &tmp_path, &tmp_file);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "select PUK file");
+	LOG_TEST_RET(card->ctx, rv, "select PUK file");
 
 	if (!tmp_file || tmp_file->size < OBERTHUR_AUTH_MAX_LENGTH_PUK)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_TOO_SMALL, "Oberthur style 'PIN RESET' failed");
+		LOG_TEST_RET(card->ctx, SC_ERROR_FILE_TOO_SMALL, "Oberthur style 'PIN RESET' failed");
 
 	rv = iso_ops->read_binary(card, 0, puk, OBERTHUR_AUTH_MAX_LENGTH_PUK, 0);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "read PUK file error");
+	LOG_TEST_RET(card->ctx, rv, "read PUK file error");
 	if (rv != OBERTHUR_AUTH_MAX_LENGTH_PUK)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA, "Oberthur style 'PIN RESET' failed");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Oberthur style 'PIN RESET' failed");
 
 	memset(ffs1, 0xFF, sizeof(ffs1));
 	memcpy(ffs1, puk, rv);
@@ -1828,7 +1824,7 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
 	if (data->pin2.data)   {
 		memcpy(&pin_cmd.pin2, &data->pin2, sizeof(pin_cmd.pin2));
 		rv = auth_pin_reset(card, SC_AC_CHV, &pin_cmd, tries_left);
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+		LOG_FUNC_RETURN(card->ctx, rv);
 	}
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2C, 0x00, local_pin_reference);
@@ -1853,7 +1849,7 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
 
 	rvv = iso_drv->ops->pin_cmd(card, &pin_cmd, tries_left);
 	if (rvv)
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
+		sc_log(card->ctx,
 				"%s: PIN CMD 'VERIFY' with pinpad failed",
 				sc_strerror(rvv));
 
@@ -1863,7 +1859,7 @@ auth_pin_reset_oberthur_style(struct sc_card *card, unsigned int type,
 	if (rv > 0)
 		rv = 0;
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv ? rv: rvv);
+	LOG_FUNC_RETURN(card->ctx, rv ? rv: rvv);
 }
 
 
@@ -1873,13 +1869,13 @@ auth_pin_reset(struct sc_card *card, unsigned int type,
 {
 	int rv;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	/* Oberthur unblock style: PUK value is a SOPIN */
 	rv = auth_pin_reset_oberthur_style(card, SC_AC_CHV, data, tries_left);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Oberthur style 'PIN RESET' failed");
+	LOG_TEST_RET(card->ctx, rv, "Oberthur style 'PIN RESET' failed");
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1888,31 +1884,31 @@ auth_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left
 {
 	int rv = SC_ERROR_INTERNAL;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 	if (data->pin_type != SC_AC_CHV)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "auth_pin_cmd() unsupported PIN type");
+		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "auth_pin_cmd() unsupported PIN type");
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIN CMD:%i; reference:%i; pin1:%p/%i, pin2:%p/%i\n", data->cmd,
+	sc_log(card->ctx, "PIN CMD:%i; reference:%i; pin1:%p/%i, pin2:%p/%i", data->cmd,
 			data->pin_reference, data->pin1.data, data->pin1.len,
 			data->pin2.data, data->pin2.len);
 	switch (data->cmd) {
 	case SC_PIN_CMD_VERIFY:
 		rv = auth_pin_verify(card, SC_AC_CHV, data, tries_left);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "CMD 'PIN VERIFY' failed");
+		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
 		break;
 	case SC_PIN_CMD_CHANGE:
 		rv = auth_pin_change(card, SC_AC_CHV, data, tries_left);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "CMD 'PIN VERIFY' failed");
+		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
 		break;
 	case SC_PIN_CMD_UNBLOCK:
 		rv = auth_pin_reset(card, SC_AC_CHV, data, tries_left);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "CMD 'PIN VERIFY' failed");
+		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
 		break;
 	default:
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN operation");
+		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN operation");
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1925,43 +1921,43 @@ auth_create_reference_data (struct sc_card *card,
 	int rv, len;
 	unsigned char sbuf[SC_MAX_APDU_BUFFER_SIZE];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIN reference %i\n", args->ref);
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "PIN reference %i", args->ref);
 
 	if (args->type != SC_AC_CHV)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN type");
+		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN type");
 
 	if (args->pin_tries < 1 || !args->pin || !args->pin_len)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid PIN options");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid PIN options");
 
 	if (args->ref != OBERTHUR_PIN_REFERENCE_USER && args->ref != OBERTHUR_PIN_REFERENCE_PUK)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid PIN reference");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid PIN reference");
 
 	auth_init_pin_info(card, &puk_info, OBERTHUR_AUTH_TYPE_PUK);
 	auth_init_pin_info(card, &pin_info, OBERTHUR_AUTH_TYPE_PIN);
 
 	if (args->puk && args->puk_len && (args->puk_len%puk_info.pad_length))
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid PUK options");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid PUK options");
 
 	len = 0;
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "len %i", len);
+	sc_log(card->ctx, "len %i", len);
 	sbuf[len++] = args->pin_tries;
 	sbuf[len++] = pin_info.pad_length;
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "len %i", len);
+	sc_log(card->ctx, "len %i", len);
 	memset(sbuf + len, pin_info.pad_char, pin_info.pad_length);
 	memcpy(sbuf + len, args->pin, args->pin_len);
 	len += pin_info.pad_length;
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "len %i", len);
+	sc_log(card->ctx, "len %i", len);
 
 	if (args->puk && args->puk_len)   {
 		sbuf[len++] = args->puk_tries;
 		sbuf[len++] = args->puk_len / puk_info.pad_length;
-		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "len %i", len);
+		sc_log(card->ctx, "len %i", len);
 		memcpy(sbuf + len, args->puk, args->puk_len);
 		len += args->puk_len;
 	}
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "len %i", len);
+	sc_log(card->ctx, "len %i", len);
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 1, args->ref & ~OBERTHUR_PIN_LOCAL);
 	apdu.data = sbuf;
 	apdu.datalen = len;
@@ -1969,11 +1965,11 @@ auth_create_reference_data (struct sc_card *card,
 
 	rv = sc_transmit_apdu(card, &apdu);
 	sc_mem_clear(sbuf, sizeof(sbuf));
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -1986,17 +1982,17 @@ auth_logout(struct sc_card *card)
 
 	for (ii=0; ii < 4; ii++)   {
 		rv = auth_get_pin_reference (card, SC_AC_CHV, ii+1, SC_PIN_CMD_UNBLOCK, &pin_ref);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot get PIN reference");
+		LOG_TEST_RET(card->ctx, rv, "Cannot get PIN reference");
 
 		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x2E, 0x00, 0x00);
 		apdu.cla = 0x80;
 		apdu.p2 = pin_ref | reset_flag;
 		rv = sc_transmit_apdu(card, &apdu);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -2010,16 +2006,16 @@ write_publickey (struct sc_card *card, unsigned int offset,
 	size_t len = 0, der_size = 0;
 	char debug_buf[2048];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	LOG_FUNC_CALLED(card->ctx);
 
 	debug_buf[0] = 0;
 	sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL,
 		buf, count, debug_buf, sizeof(debug_buf));
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
+	sc_log(card->ctx,
 		"write_publickey in %d bytes :\n%s", count, debug_buf);
 
 	if (1+offset > sizeof(rsa_der))
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid offset value");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid offset value");
 
 	len = offset+count > sizeof(rsa_der) ? sizeof(rsa_der) - offset : count;
 
@@ -2034,14 +2030,14 @@ write_publickey (struct sc_card *card, unsigned int offset,
 			der_size = rsa_der[1];
 	}
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "der_size %i\n",der_size);
+	sc_log(card->ctx, "der_size %i",der_size);
 	if (offset + len < der_size + 2)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len);
+		LOG_FUNC_RETURN(card->ctx, len);
 
 	rv = sc_pkcs15_decode_pubkey_rsa(card->ctx, &key, rsa_der, rsa_der_len);
 	rsa_der_len = 0;
 	memset(rsa_der, 0, sizeof(rsa_der));
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "cannot decode public key");
+	LOG_TEST_RET(card->ctx, rv, "cannot decode public key");
 
 	memset(&args, 0, sizeof(args));
 	args.type = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
@@ -2049,7 +2045,7 @@ write_publickey (struct sc_card *card, unsigned int offset,
 	args.data = key.modulus.data;
 	args.len = key.modulus.len;
 	rv = auth_update_component(card, &args);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Update component failed");
+	LOG_TEST_RET(card->ctx, rv, "Update component failed");
 
 	memset(&args, 0, sizeof(args));
 	args.type = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
@@ -2057,9 +2053,9 @@ write_publickey (struct sc_card *card, unsigned int offset,
 	args.data = key.exponent.data;
 	args.len = key.exponent.len;
 	rv = auth_update_component(card, &args);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Update component failed");
+	LOG_TEST_RET(card->ctx, rv, "Update component failed");
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len);
+	LOG_FUNC_RETURN(card->ctx, len);
 }
 
 
@@ -2069,13 +2065,13 @@ auth_update_binary(struct sc_card *card, unsigned int offset,
 {
 	int rv = 0;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "offset %i; count %i\n", offset, count);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "last selected : magic %X; ef %X\n",
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "offset %i; count %i", offset, count);
+	sc_log(card->ctx, "last selected : magic %X; ef %X",
 			auth_current_ef->magic, auth_current_ef->ef_structure);
 
 	if (offset & ~0x7FFF)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
 
 	if (auth_current_ef->magic==SC_FILE_MAGIC &&
 			 auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)  {
@@ -2095,7 +2091,7 @@ auth_update_binary(struct sc_card *card, unsigned int offset,
 		rv = iso_ops->update_binary(card, offset, buf, count, 0);
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -2106,13 +2102,13 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 	int rv;
 	char debug_buf[2048];
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"offset %i; size %i; flags 0x%lX\n", offset, count, flags);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"last selected : magic %X; ef %X\n",
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx,"offset %i; size %i; flags 0x%lX", offset, count, flags);
+	sc_log(card->ctx,"last selected : magic %X; ef %X",
 			auth_current_ef->magic, auth_current_ef->ef_structure);
 
 	if (offset & ~0x7FFF)
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
+		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
 
 	if (auth_current_ef->magic==SC_FILE_MAGIC &&
 			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)   {
@@ -2125,7 +2121,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 		resp_len = sizeof(resp);
 		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 				2, resp, resp_len);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "read component failed");
+		LOG_TEST_RET(card->ctx, rv, "read component failed");
 
 		for (jj=0; jj<rv && *(resp+jj)==0; jj++)
 			;
@@ -2136,7 +2132,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 
 		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 				1, resp, resp_len);
-		SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot read RSA public key component");
+		LOG_TEST_RET(card->ctx, rv, "Cannot read RSA public key component");
 
 		bn[1].data = calloc(1, rv);
 		bn[1].len = rv;
@@ -2146,7 +2142,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 		key.modulus = bn[1];
 
 		if (sc_pkcs15_encode_pubkey_rsa(card->ctx, &key, &out, &out_len)) {
-			SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ASN1_OBJECT,
+			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ASN1_OBJECT,
 					"cannot encode RSA public key");
 		}
 		else {
@@ -2156,7 +2152,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 			debug_buf[0] = 0;
 			sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL,
 				buf, rv, debug_buf, sizeof(debug_buf));
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
+			sc_log(card->ctx,
 				"write_publickey in %d bytes :\n%s",
 				count, debug_buf);
 		}
@@ -2172,7 +2168,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
 		rv = iso_ops->read_binary(card, offset, buf, count, 0);
 	}
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -2184,7 +2180,7 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec,
 	int rv = 0;
 	unsigned char recvbuf[SC_MAX_APDU_BUFFER_SIZE];
 
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "auth_read_record(): nr_rec %i; count %i\n", nr_rec, count);
+	sc_log(card->ctx, "auth_read_record(): nr_rec %i; count %i", nr_rec, count);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, nr_rec, 0);
 	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
@@ -2196,15 +2192,15 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec,
 	apdu.resp = recvbuf;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 	if (apdu.resplen == 0)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
+		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
 	memcpy(buf, recvbuf, apdu.resplen);
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "Card returned error");
+	LOG_TEST_RET(card->ctx, rv, "Card returned error");
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, apdu.resplen);
+	LOG_FUNC_RETURN(card->ctx, apdu.resplen);
 }
 
 
@@ -2214,17 +2210,17 @@ auth_delete_record(struct sc_card *card, unsigned int nr_rec)
 	struct sc_apdu apdu;
 	int rv = 0;
 
-	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
-	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "auth_delete_record(): nr_rec %i\n", nr_rec);
+	LOG_FUNC_CALLED(card->ctx);
+	sc_log(card->ctx, "auth_delete_record(): nr_rec %i", nr_rec);
 
 	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x32, nr_rec, 0x04);
 	apdu.cla = 0x80;
 
 	rv = sc_transmit_apdu(card, &apdu);
-	SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, rv, "APDU transmit failed");
+	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
 
 	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, rv);
+	LOG_FUNC_RETURN(card->ctx, rv);
 }
 
 
@@ -2232,14 +2228,14 @@ static int
 auth_get_serialnr(struct sc_card *card, struct sc_serial_number *serial)
 {
 	if (!serial)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
 
 	if (card->serialnr.len==0)
-		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
+		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
 
 	memcpy(serial, &card->serialnr, sizeof(*serial));
 
-	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
 }
 
 
@@ -2258,7 +2254,7 @@ auth_check_sw(struct sc_card *card, unsigned int sw1, unsigned int sw2)
 
 	for (ii=0; auth_warnings[ii].SWs; ii++)   {
 		if (auth_warnings[ii].SWs == ((sw1 << 8) | sw2))   {
-			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", auth_warnings[ii].errorstr);
+			sc_log(card->ctx, "%s", auth_warnings[ii].errorstr);
 			return auth_warnings[ii].errorno;
 		}
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list