Skip to content
Elisey Zamakhov (GitHub) edited this page Aug 16, 2016 · 1 revision

The are 6 logging levels in SDL implementation:

FATAL

Indicates, that SDL has an abnormal problem and will be stopped (or shut down) immediately. It also can mean that the current status is UB or SDL was interrupted with SegFault.

if (!life_cycle.InitMessageSystem()) {
	SDL_FATAL("Failed to init message system");
	life_cycle.StopComponents();
	exit(EXIT_FAILURE);
}

ERROR

Shows, that an error occurred and SDL has not accomplished some internal or API activities, but this error was correctly handled and SDL continued working

// DeleteCommandRequest
ApplicationSharedPtr app = application_manager_.application(connection_key());
if (!app) {
	SDL_ERROR("Application is not registered");
	SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED);
	return;
}

WARNING

Warns against a not commonplace, but expected behavior, which was successfully handled by SDL.

// ProtocolHandlerImpl
if (result == RESULT_MALFORMED_OCCURS) {
	SDL_WARN("Malformed message occurs, connection id " << connection_key);
	...
}

INFO

Informs SDL's user, integrator or support engineer about the current component high-level activity success.

// ConnectionHandlerImpl
SDL_INFO("Disconnect flooding application");
CloseSession(connection_handle, session_id, kFlood);

// MediaManagerImpl
SDL_INFO("StartMicrophoneRecording to " << output_file);
 
// PolicyManagerImpl
SDL_INFO("Policy table updated from " << (b ? "cloud" : "preloaded") << path);

// TransportManager - TcpClientListener
const utils::HostAddress client_address = client_connection.GetAddress();
SDL_INFO("Connected client " << client_address.ToString() << ":"
                             << client_connection.GetPort());

DEBUG

Is a devlopers-only information, which can help to debug an issue by log

// ProtocolHandlerImpl
SDL_DEBUG("Protocol version: " << packet.protocol_version());

// ProtocolHandlerImpl
SDL_DEBUG("Frequency of " << connection_key << " is " << message_frequency);

// SecurityManagerImpl
if (sslContext->IsInitCompleted()) {
	SDL_DEBUG("SSL initialization finished success.");
	NotifyListenersOnHandshakeDone(	connection_key,
									SSLContext::Handshake_Result_Success);
}

TRACE

Low-level tracing information. The common places for TRACE macro is - expected cases of switch, return. beginning or/and end of code block: method, if-else statement

// ProtocolHandlerImpl
switch (packet->frame_type()) {
  case FRAME_TYPE_CONTROL:
    SDL_TRACE("handleMessage() - case FRAME_TYPE_CONTROL");
    return HandleControlMessage(connection_id, packet);
  ...
}

// Utils - Thread
if (isThreadRunning_) {
  SDL_TRACE("EXIT thread "<< name_ << " #" << handle_ << " is already running");
  return true;
}

// TransportManagerDefault::Init
SDL_TRACE("exit with E_SUCCESS");
return E_SUCCESS;

Note:

There is a common situation, when pretty hard to choose between two nearby levels. In this case use the lower level.