From b3db0e6ee14315d20ca91eff91e348e18dd119e6 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 13 May 2016 11:53:33 +0100 Subject: translate logging.cpp to C --- src/session.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/session.cpp') diff --git a/src/session.cpp b/src/session.cpp index 6a9bb7e..816dd26 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -16,7 +16,7 @@ #include "olm/cipher.hh" #include "olm/crypto.hh" #include "olm/account.hh" -#include "olm/logging.hh" +#include "olm/logging.h" #include "olm/memory.hh" #include "olm/message.hh" #include "olm/pickle.hh" @@ -68,7 +68,7 @@ std::size_t olm::Session::new_outbound_session( return std::size_t(-1); } - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Creating new outbound session to receiver identity IB %s, " "receiver ephemeral EB %s", identity_key.to_string().c_str(), one_time_key.to_string().c_str() @@ -76,12 +76,12 @@ std::size_t olm::Session::new_outbound_session( olm::Curve25519KeyPair base_key; olm::curve25519_generate_key(random, base_key); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Created new ephemeral key EA %s", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created new ephemeral key EA %s", base_key.to_string().c_str()); olm::Curve25519KeyPair ratchet_key; olm::curve25519_generate_key(random + olm::KEY_LENGTH, ratchet_key); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Created new ratchet key T(0) %s", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created new ratchet key T(0) %s", ratchet_key.to_string().c_str()); olm::Curve25519KeyPair const & alice_identity_key_pair = ( @@ -108,7 +108,7 @@ std::size_t olm::Session::new_outbound_session( olm::unset(ratchet_key); olm::unset(secret); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised outbound session"); + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised outbound session"); return std::size_t(0); } @@ -151,7 +151,7 @@ std::size_t olm::Session::new_inbound_session( their_identity_key->public_key, reader.identity_key, olm::KEY_LENGTH ); if (!same) { - olm::logf(olm::LOG_INFO, LOG_CATEGORY, + olm_logf(OLM_LOG_INFO, LOG_CATEGORY, "Identity key on received message is incorrect " "(expected %s, got %s)", their_identity_key->to_string().c_str(), @@ -167,7 +167,7 @@ std::size_t olm::Session::new_inbound_session( olm::load_array(alice_base_key.public_key, reader.base_key); olm::load_array(bob_one_time_key.public_key, reader.one_time_key); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Creating new inbound session from sender identity IA %s, " "sender ephemeral EA %s, our ephemeral EB %s", alice_identity_key.to_string().c_str(), @@ -189,7 +189,7 @@ std::size_t olm::Session::new_inbound_session( olm::Curve25519PublicKey ratchet_key; olm::load_array(ratchet_key.public_key, message_reader.ratchet_key); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Received ratchet key T(0) %s", ratchet_key.to_string().c_str()); olm::OneTimeKey const * our_one_time_key = local_account.lookup_key( @@ -197,7 +197,7 @@ std::size_t olm::Session::new_inbound_session( ); if (!our_one_time_key) { - olm::logf(olm::LOG_INFO, LOG_CATEGORY, + olm_logf(OLM_LOG_INFO, LOG_CATEGORY, "Session uses unknown ephemeral key %s", bob_one_time_key.to_string().c_str()); last_error = olm::ErrorCode::BAD_MESSAGE_KEY_ID; @@ -221,7 +221,7 @@ std::size_t olm::Session::new_inbound_session( olm::unset(secret); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised inbound session"); + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised inbound session"); return std::size_t(0); } @@ -320,7 +320,7 @@ std::size_t olm::Session::encrypt( std::uint8_t const * random, std::size_t random_length, std::uint8_t * message, std::size_t message_length ) { - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Encrypting '%.*s'", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Encrypting '%.*s'", (int)plaintext_length, plaintext); if (message_length < encrypt_message_length(plaintext_length)) { @@ -351,7 +351,7 @@ std::size_t olm::Session::encrypt( message_body = writer.message; - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Encoded pre-key message ver=%i one_time_key[Eb]=%s " "base_key[Ea]=%s identity_key[Ia]=%s", PROTOCOL_VERSION, @@ -373,7 +373,7 @@ std::size_t olm::Session::encrypt( return result; } - olm::logf(olm::LOG_TRACE, LOG_CATEGORY, "Encrypted message %s", + olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, "Encrypted message %s", olm::bytes_to_string(message_body, result).c_str()); return result; @@ -417,7 +417,7 @@ std::size_t olm::Session::decrypt( std::uint8_t const * message, std::size_t message_length, std::uint8_t * plaintext, std::size_t max_plaintext_length ) { - olm::logf(olm::LOG_TRACE, LOG_CATEGORY, "Decrypting %smessage", + olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, "Decrypting %smessage", message_type == olm::MessageType::MESSAGE ? "" : "pre-key "); std::uint8_t const * message_body; @@ -447,7 +447,7 @@ std::size_t olm::Session::decrypt( } received_message = true; - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Decrypted '%.*s'", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Decrypted '%.*s'", (int)result, plaintext); return result; } -- cgit v1.2.3