Skip to content

Commit

Permalink
some mor incorrect usages of slf4j Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Hajo.Thelen committed Dec 4, 2024
1 parent a73415e commit 14aad3c
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 40 deletions.
28 changes: 14 additions & 14 deletions mjsip-examples/src/main/java/org/mjsip/examples/UserAgentCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class UserAgentCli implements UserAgentListenerAdapter {
/** Changes the call state */
protected void changeStatus(String state) {
call_state=state;
LOG.debug("state: "+call_state);
LOG.debug("state: {}", call_state);
}

/** Checks the call state */
Expand Down Expand Up @@ -150,7 +150,7 @@ public void readyToReceive() {

/** Makes a new call */
public void call(String target_uri) {
LOG.info("CALLING " + target_uri);
LOG.info("CALLING {}", target_uri);
ua.call(target_uri, mediaAgent());
changeStatus(UA_OUTGOING_CALL);
}
Expand Down Expand Up @@ -271,7 +271,7 @@ public void onUaIncomingCall(UserAgent ua, NameAddress callee, NameAddress calle
if (_uiConfig.redirectTo!=null) {
// redirect the call
ua.redirect(_uiConfig.redirectTo);
LOG.info("call redirected to "+_uiConfig.redirectTo);
LOG.info("call redirected to {}",_uiConfig.redirectTo);
}
else
if (_uiConfig.acceptTime>=0) {
Expand All @@ -281,21 +281,21 @@ public void onUaIncomingCall(UserAgent ua, NameAddress callee, NameAddress calle
}
else {
changeStatus(UA_INCOMING_CALL);
LOG.info("incoming call from "+caller.toString());
LOG.info("incoming call from {}", caller.toString());
LOG.info("accept? [yes/no]");
}
}

/** When an ougoing call is stated to be in progress */
@Override
public void onUaCallProgress(UserAgent ua) {

// noop
}

/** When an ougoing call is remotly ringing */
@Override
public void onUaCallRinging(UserAgent ua) {

// noop
}

/** When an ougoing call has been accepted */
Expand All @@ -311,7 +311,7 @@ public void onUaCallAccepted(UserAgent ua) {
/** When a call has been transferred */
@Override
public void onUaCallTransferred(UserAgent ua) {

// noop
}

/** When an incoming call has been cancelled */
Expand Down Expand Up @@ -350,13 +350,13 @@ public void onUaMediaSessionStopped(UserAgent ua, String type) {
/** When registration succeeded. */
@Override
public void onUaRegistrationSucceeded(UserAgent ua, String result) {
LOG.info("Registration succeeded: "+result);
LOG.info("Registration succeeded: {}", result);
}

/** When registration failed. */
@Override
public void onUaRegistrationFailed(UserAgent ua, String result) {
LOG.error("Registration failed: "+result);
LOG.error("Registration failed: {}", result);
}


Expand All @@ -373,7 +373,7 @@ public void doWork() {
}*/
/** Schedules a re-inviting after <i>delay_time</i> secs. It simply changes the contact address. */
void reInvite(final int delay_time) {
LOG.info("AUTOMATIC RE-INVITING/MODIFING: "+delay_time+" secs");
LOG.info("AUTOMATIC RE-INVITING/MODIFING: {} secs", delay_time);
if (delay_time==0) ua.modify(null);
else
sip_provider.scheduler().schedule(delay_time*1000L, () -> ua.modify(null));
Expand All @@ -391,7 +391,7 @@ public void doWork() {
}*/
/** Schedules a call-transfer after <i>delay_time</i> secs. */
void callTransfer(final NameAddress transfer_to, final int delay_time) {
LOG.info("AUTOMATIC REFER/TRANSFER: "+delay_time+" secs");
LOG.info("AUTOMATIC REFER/TRANSFER: {} secs", delay_time);
if (delay_time==0) ua.transfer(transfer_to);
else
sip_provider.scheduler().schedule(delay_time*1000L, () -> ua.transfer(transfer_to));
Expand All @@ -408,7 +408,7 @@ public void doWork() {
}*/
/** Schedules an automatic answer after <i>delay_time</i> secs. */
void automaticAccept(final int delay_time) {
LOG.info("AUTOMATIC ANSWER: "+delay_time+" secs");
LOG.info("AUTOMATIC ANSWER: {} secs", delay_time);
if (delay_time==0) accept();
else
sip_provider.scheduler().schedule(delay_time*1000L, this::accept);
Expand All @@ -425,15 +425,15 @@ public void doWork() {
}*/
/** Schedules an automatic hangup after <i>delay_time</i> secs. */
void automaticHangup(final int delay_time) {
LOG.info("AUTOMATIC HANGUP: "+delay_time+" secs");
LOG.info("AUTOMATIC HANGUP: {} secs", delay_time);
if (delay_time==0) hangup();
else
sip_provider.scheduler().schedule(delay_time*1000L, this::hangup);
}

/** Schedules an automatic re-call after <i>delay_time</i> secs. */
void automaticCall(final int delay_time, final String remote_uri) {
LOG.info("AUTOMATIC RE-CALL: "+delay_time+" secs");
LOG.info("AUTOMATIC RE-CALL: {} secs", delay_time);
if (delay_time==0) call(remote_uri);
else
sip_provider.scheduler().schedule(delay_time*1000L, () -> call(remote_uri));
Expand Down
10 changes: 5 additions & 5 deletions mjsip-sip/src/main/java/org/mjsip/sip/dialog/InviteDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void refuse() {
* See {@link SipResponses}.
*/
public void refuse(int code, String reason) {
LOG.debug("inside refuse("+code+","+((reason!=null)?reason:SipResponses.reasonOf(code))+")");
LOG.debug("inside refuse({},{})", code, (reason != null) ? reason : SipResponses.reasonOf(code));
respond(code,reason,null,null,null);
}

Expand All @@ -472,7 +472,7 @@ public void refuse(int code, String reason) {
* See {@link SipResponses}.
*/
public void redirect(int code, String reason, NameAddress contact) {
LOG.debug("inside redirect("+code+","+reason+","+contact.toString()+")");
LOG.debug("inside redirect({},{},{})", code, reason, contact);
respond(code,reason,contact,null,null);
}

Expand All @@ -490,7 +490,7 @@ public void redirect(int code, String reason, NameAddress contact) {
* the message body to be included within the response message, or <i>null</i>
*/
public void respond(int code, String reason, NameAddress contact, String content_type, byte[] body) {
LOG.debug("inside respond("+code+","+reason+")");
LOG.debug("inside respond({},{})", code, reason);
if (statusIs(DialogStatus.D_INVITED) || statusIs(DialogStatus.D_ReINVITED)) {
SipMessage resp=sipMessageFactory.createResponse(invite_req,code,reason,contact);
resp.setBody(content_type,body);
Expand All @@ -501,7 +501,7 @@ public void respond(int code, String reason, NameAddress contact, String content
respond(resp);
}
else {
LOG.warn("Dialog isn't in \"invited\" state: cannot respond ("+code+"/"+getStatus()+"/"+getDialogID()+")");
LOG.warn("Dialog isn't in \"invited\" state: cannot respond ({}/{}/{})", code, getStatus(), getDialogID());
}
}

Expand Down Expand Up @@ -1073,7 +1073,7 @@ public void onTransProvisionalResponse(TransactionClient tc, SipMessage msg) {
* removes the listener from SipProvider, and fires <i>onClose(this,msg)</i>. */
@Override
public void onTransFailureResponse(TransactionClient tc, SipMessage msg) {
LOG.debug("inside onTransFailureResponse("+tc.getTransactionId()+",msg)");
LOG.debug("inside onTransFailureResponse({},{})", tc.getTransactionId(), msg);
if (tc.getTransactionMethod().equals(SipMethods.INVITE)) {
if (!verifyStatus("INVITE failure response requires INVITING state.",
statusIs(DialogStatus.D_INVITING) || statusIs(DialogStatus.D_ReINVITING))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public AckTransactionClient(SipProvider sip_provider, SipMessage ack, Transactio
request=new SipMessage(ack);
transaction_listener=listener;
transaction_id=SipId.createTransactionClientId(request);
LOG.info("new transaction-id: "+transaction_id.toString());
LOG.info("new transaction-id: {}", transaction_id);
}

/** Starts the AckTransactionClient and sends the ACK request. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void init(TransactionClientListener listener, SipId transaction_id) {
this.transaction_id=transaction_id;
this.ack=null;
// init the timer just to set the timeout value and label, without listener (never started)
LOG.info("new transaction-id: "+transaction_id.toString());
LOG.info("new transaction-id: {}", transaction_id);
}


Expand Down Expand Up @@ -159,7 +159,8 @@ private void onTransmission() {

scheduleRetransmission(sip_provider.sipConfig().getRetransmissionTimeout());
}
else LOG.trace("No retransmissions for reliable transport ("+connection_id+")");
else
LOG.trace("No retransmissions for reliable transport ({})", connection_id);
}

/** Terminates the transaction. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void init(InviteTransactionServerListener listener, SipId transaction_id, Connec
auto_trying=sip_provider.sipConfig().isAutoTrying();
// init the timer just to set the timeout value and label, without listener (never started)
if (LOG.isDebugEnabled()) {
LOG.debug("new transaction-id: " + transaction_id.toString());
LOG.debug("new transaction-id: {}", transaction_id);
}
}

Expand Down Expand Up @@ -164,7 +164,7 @@ public void respondWith(SipMessage resp) {
//end_to.start();
}
else {
LOG.trace("No retransmissions for reliable transport ("+connection_id+")");
LOG.trace("No retransmissions for reliable transport ({})", connection_id);
//onTimeout(end_to);
}
end_to = sip_provider.scheduler().schedule(sip_provider.sipConfig().getTransactionTimeout(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ public synchronized void processPrack(SipProvider sip_provider, SipMessage prack
if (listener!=null) listener.onReliableProvisionalResponseConfirmation(this,resp,prack);
if (retransmission_to==null && hasPendingResponses()) sendNextResponse();
}
else LOG.warn(prack.getRequestLine().getMethod()+" confirmation received for past response?");
else LOG.warn("{} confirmation received for past response?", prack.getRequestLine().getMethod());
}
else LOG.warn(prack.getRequestLine().getMethod()+" no provisional response waiting for confirmation has been found");
else LOG.warn("{} no provisional response waiting for confirmation has been found", prack.getRequestLine().getMethod());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected Transaction(SipProvider sip_provider) {
protected void changeStatus(int newstatus) {
status=newstatus;
//transaction_listener.onChangedTransactionStatus(status);
LOG.debug("changed transaction state: "+getStatus());
LOG.debug("changed transaction state: {}", getStatus());
}

/** Whether the internal status is equal to <i>st</i> */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void init(TransactionServerListener listener, SipId transaction_id, Co
this.response=null;
// init the timer just to set the timeout value and label, without listener (never started)
if (LOG.isDebugEnabled()) {
LOG.debug("Starting transaction " + transaction_id.toString() + ": " + request);
LOG.debug("Starting transaction {}:{}", transaction_id, request);
}
}

Expand Down Expand Up @@ -119,7 +119,7 @@ public void respondWith(int code) {
/** Sends a response message */
public void respondWith(SipMessage resp) {
if (LOG.isDebugEnabled()) {
LOG.debug("Transaction " + transaction_id.toString() + " response: " + resp);
LOG.debug("Transaction {} response: {}", transaction_id, resp);
}

response=resp;
Expand Down Expand Up @@ -155,7 +155,7 @@ public void terminate() {
@Override
public void onReceivedMessage(SipProvider provider, SipMessage msg) {
if (LOG.isDebugEnabled()) {
LOG.debug("Transaction " + transaction_id.toString() + ": " + msg);
LOG.debug("Transaction {}:{}", transaction_id, msg);
}

if (msg.isRequest()) {
Expand All @@ -182,7 +182,7 @@ public void onReceivedMessage(SipProvider provider, SipMessage msg) {

protected void onClearingTimeout() {
if (LOG.isDebugEnabled()) {
LOG.debug("Transaction timeout reached: " + transaction_id.toString());
LOG.debug("Transaction timeout reached: {}", transaction_id);
}
doTerminate();
}
Expand All @@ -200,7 +200,7 @@ protected void doTerminate() {
changeStatus(STATE_TERMINATED);

if (LOG.isDebugEnabled()) {
LOG.debug("Transaction terminated: " + transaction_id.toString());
LOG.debug("Transaction terminated: {}", transaction_id);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ protected void register(int expire_time, String content_type, byte[] body) {
req.setAuthorizationHeader(ah);
}
if (body!=null) {
LOG.debug("Register body type: " + content_type + "; length: " + body.length + " bytes");
LOG.debug("Register body type: {}; length: {} bytes", content_type, body.length);
req.setBody(content_type,body);
}

if (LOG.isDebugEnabled()) {
if (expire_time > 0) {
LOG.debug("Registering " + _contactNAddr + " (expiry " + expire_time + " secs) at " + _registrarUri);
LOG.debug("Registering {} (expiry {} secs) at {}", _contactNAddr, expire_time, _registrarUri);
} else {
LOG.debug("Unregistering " + _contactNAddr + " from " + _registrarUri);
LOG.debug("Unregistering {} from {}", _contactNAddr, _registrarUri);
}
}

Expand Down Expand Up @@ -405,7 +405,7 @@ public void onTransFailureResponse(TransactionClient transaction, SipMessage res
req.addViaHeader(vh);
WwwAuthenticateHeader wah=resp.getWwwAuthenticateHeader();
String qop_options=wah.getQopOptionsParam();
//LOG.debug("qop-options: "+qop_options);
//LOG.debug("qop-options: {}", qop_options);
_qop=(qop_options!=null)? "auth" : null;
AuthorizationHeader ah=(new DigestAuthentication(SipMethods.REGISTER,req.getRequestLine().getAddress().toString(),wah,_qop,null,0,null,_username,_passwd)).getAuthorizationHeader();
req.setAuthorizationHeader(ah);
Expand All @@ -420,7 +420,7 @@ public void onTransFailureResponse(TransactionClient transaction, SipMessage res
req.setCSeqHeader(req.getCSeqHeader().incSequenceNumber());
ProxyAuthenticateHeader pah=resp.getProxyAuthenticateHeader();
String qop_options=pah.getQopOptionsParam();
//LOG.debug("qop-options: "+qop_options);
//LOG.debug("qop-options: {}", qop_options);
_qop=(qop_options!=null)? "auth" : null;
ProxyAuthorizationHeader ah=(new DigestAuthentication(SipMethods.REGISTER,req.getRequestLine().getAddress().toString(),pah,_qop,null,0,null,_username,_passwd)).getProxyAuthorizationHeader();
req.setProxyAuthorizationHeader(ah);
Expand All @@ -429,7 +429,7 @@ public void onTransFailureResponse(TransactionClient transaction, SipMessage res
} else {
// Registration failure
String result=code+" "+status.getReason();
LOG.info("Registration of " + _contactNAddr + " failed: "+result);
LOG.info("Registration of {} failed: {}",_contactNAddr, result);
if (_listener != null) {
_listener.onRegistrationFailure(this, _toNAddr, _contactNAddr, result);
}
Expand All @@ -444,7 +444,7 @@ public void onTransFailureResponse(TransactionClient transaction, SipMessage res
@Override
public void onTransTimeout(TransactionClient transaction) {
if (transaction.getTransactionMethod().equals(SipMethods.REGISTER)) {
LOG.info("Registration of " + _contactNAddr + " timed out.");
LOG.info("Registration of {} timed out.", _contactNAddr);
if (_listener != null) {
_listener.onRegistrationFailure(this, _toNAddr, _contactNAddr, "Timeout");
}
Expand Down Expand Up @@ -472,7 +472,7 @@ private void scheduleNextAttempt(long timeout) {

_attemptTimer = _sipProvider.scheduler().schedule(timeout, this::onAttemptTimeout);

LOG.info("Waiting " + (timeout / 1000) + "s for next registration of " + _contactNAddr + ".");
LOG.info("Waiting {}ms for next registration of {}.", timeout, _contactNAddr);
}


Expand Down

0 comments on commit 14aad3c

Please sign in to comment.