Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned logging #22

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected UserAgentListener createCallHandler(SipMessage msg) {
@Override
public void onUaIncomingCall(UserAgent ua, NameAddress callee, NameAddress caller,
MediaDesc[] media_descs) {
LOG.info("Incomming call from: " + callee.getAddress());
LOG.info("Incomming call from: {}", callee.getAddress());
ua.accept(new MediaAgent(_mediaConfig.getMediaDescs(), _streamerFactory));
}
};
Expand All @@ -98,7 +98,7 @@ public void onUaIncomingCall(UserAgent ua, NameAddress callee, NameAddress calle
* The main entry point.
*/
public static void main(String[] args) throws UnsupportedAudioFileException, IOException {
LOG.info(AnsweringMachine.class.getSimpleName() + " " + SipStack.version);
LOG.info("{} {}", AnsweringMachine.class.getSimpleName(), SipStack.version);

SipConfig sipConfig = new SipConfig();
UAConfig uaConfig = new UAConfig();
Expand All @@ -115,7 +115,7 @@ public static void main(String[] args) throws UnsupportedAudioFileException, IOE

if (mediaConfig.getSendFile() != null) {
AudioFileFormat audioFormat = AudioSystem.getAudioFileFormat(new File(mediaConfig.getSendFile()));
LOG.info("Announcement file format: " + audioFormat);
LOG.info("Announcement file format: {}", audioFormat);
}

StreamerFactory streamerFactory = ExampleStreamerFactory.createStreamerFactory(mediaConfig, uaConfig);
Expand Down
2 changes: 1 addition & 1 deletion mjsip-examples/src/main/java/org/mjsip/examples/Echo.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onReceivedMessage(SipProvider sip_provider, SipMessage msg) {
NameAddress sender=msg.getFromHeader().getNameAddress();
String content_type=msg.getContentTypeHeader().getContentType();
byte[] content=msg.getBody();
LOG.info("message received: "+new String(content));
LOG.info("message received: {}", new String(content)); //not so nice, but if you want the bytes as characters ...
// respond
TransactionServer ts=new TransactionServer(sip_provider,msg,null);
ts.respondWith(SipResponses.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,22 @@ public void send(String recipient, String subject, String text) {
public void onMaReceivedMessage(MessageAgent ma, NameAddress sender, NameAddress recipient, String subject, String content_type, String content) {
remote_user=sender;
LOG.info("NEW MESSAGE:");
LOG.info("From: " + sender);
LOG.info("From: {}", sender);
if (subject != null)
LOG.info("Subject: " + subject);
LOG.info("Content: " + content);
LOG.info("Subject: {}", subject);
LOG.info("Content: {}", content);
}

/** When a message delivery successes. */
@Override
public void onMaDeliverySuccess(MessageAgent ma, NameAddress recipient, String subject, String result) {
//LOG.info("Delivery success: "+result);
//LOG.info("Delivery success: {}", result);
}

/** When a message delivery fails. */
@Override
public void onMaDeliveryFailure(MessageAgent ma, NameAddress recipient, String subject, String result) {
//LOG.info("Delivery failure: "+result);
//LOG.info("Delivery failure: {}", result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MiniJukebox(SipProvider sip_provider, PortPool portPool, ServiceOptions s

/** From UserAgentListener. When a new call is incoming */
public void onUaIncomingCall(UserAgent ua, NameAddress callee, NameAddress caller) {
LOG.info("incoming call from "+caller.toString());
LOG.info("incoming call from {}", caller);
String audio_file=callee.getAddress().getParameter(PARAM_RESOURCE);
if (audio_file!=null) {
if (new File(audio_file).isFile()) {
Expand Down
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);
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
12 changes: 6 additions & 6 deletions mjsip-net/src/main/java/org/zoolu/net/TcpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public int getLocalPort() {
/** Stops running. */
public void halt() {
if (!stop) {
LOG.debug("Stopping TCP connection to: " + socket);
LOG.debug("Stopping TCP connection to: {}", socket);
stop = true;
}
}
Expand All @@ -152,7 +152,7 @@ public void send(byte[] buff, int offset, int len) throws IOException {
ostream.write(buff,offset,len);
ostream.flush();

LOG.debug("Sent " + len + " bytes to: " + socket);
LOG.debug("Sent {} bytes to: {}", len , socket);
}
}

Expand All @@ -166,7 +166,7 @@ public void send(byte[] buff) throws IOException {
/** Runs the tcp receiver. */
@Override
public void run() {
LOG.debug("Starting connection handler for: " + socket);
LOG.debug("Starting connection handler for: {}", socket);

byte[] buff=new byte[BUFFER_SIZE];
long expire=0;
Expand All @@ -187,7 +187,7 @@ public void run() {
}
}
if (len<0) {
LOG.debug("Connection closed: " + socket);
LOG.debug("Connection closed: {}", socket);
stop=true;
} else if (len > 0) {
if (listener!=null) listener.onReceivedData(this,buff,len);
Expand All @@ -196,7 +196,7 @@ public void run() {
}
}
catch (IOException e) {
LOG.info("TCP connection terminated: " + e.getMessage());
LOG.info("TCP connection terminated: {}", e.getMessage());
error=e;
stop=true;
}
Expand All @@ -206,7 +206,7 @@ public void run() {
if (listener!=null) listener.onConnectionTerminated(this,error);
listener=null;

LOG.debug("Connection handler terminated for: " + socket);
LOG.debug("Connection handler terminated for: {}", socket);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void saveFile(File file) {
writeTo(new FileWriter(file));
}
catch (IOException e) {
LOG.error("Failed writing file \""+file+"\"", e);
LOG.error("Failed writing file ({})", file, e);
hajothelen marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
14 changes: 7 additions & 7 deletions mjsip-phone/src/main/java/org/mjsip/phone/gui/UserAgentGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public class UserAgentGui extends JFrame 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 @@ -395,7 +395,7 @@ protected void run() {

if (_uiConfig.callTo!=null) {
// ########## make a call with the remote URI
LOG.info("UAC: CALLING " + _uiConfig.callTo);
LOG.info("UAC: CALLING {}", _uiConfig.callTo);
jComboBox1.setSelectedItem(null);
comboBoxEditor1.setItem(_uiConfig.callTo.toString());
display.setText("CALLING "+_uiConfig.callTo);
Expand Down Expand Up @@ -487,7 +487,7 @@ void comboBoxEditor1_actionPerformed(ActionEvent e) {
}

if (name==null) {
LOG.debug("No SIP URI recognized in: "+(String)comboBoxEditor1.getItem());
LOG.debug("No SIP URI recognized in: {}", (String)comboBoxEditor1.getItem());
return;
}

Expand Down Expand Up @@ -638,7 +638,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((long) (delay_time*1000), ()->ua.modify(null));
Expand All @@ -656,7 +656,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((long) (delay_time*1000), () -> ua.transfer(transfer_to));
Expand All @@ -674,7 +674,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) jButton1_actionPerformed();
else
sip_provider.scheduler().schedule((long) (delay_time*1000), this::jButton1_actionPerformed);
Expand All @@ -692,7 +692,7 @@ 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) jButton2_actionPerformed();
else
sip_provider.scheduler().schedule((long) (delay_time*1000), this::jButton2_actionPerformed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ protected SipMessage authenticateRequest(SipMessage msg, int type) {

if (!is_authorized) {
err_resp=sip_provider.messageFactory().createResponse(msg,SipResponses.FORBIDDEN,null,null);
LOG.info("Login error: Authentication of '" + user + "' failed");
LOG.info("Login error: Authentication of '{}' failed", user);
}
else {
// authentication/authorization successed
LOG.info("Authentication of '"+user+"' successed");
LOG.info("Authentication of '{}' successed", user);
}
}
else {
// authentication/authorization failed
int result=400; // response code 400 ("Bad request")
err_resp=sip_provider.messageFactory().createResponse(msg,result,null,null);
LOG.info("Authentication method '"+scheme+"' not supported.");
LOG.info("Authentication method '{}' not supported.", scheme);
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void load() {
}
if (user != null) addUser(user, key);
} catch (FileNotFoundException e) {
LOG.warn("file \"" + filename + "\" not found: created new empty DB");
LOG.warn("file \"{}\" not found: created new empty DB", filename);
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -213,7 +213,7 @@ public synchronized void save() {
out.write(this.toString());
}
catch (IOException e) {
LOG.warn("error trying to write on file \""+filename+"\"", e);
LOG.warn("error trying to write on file \"{}\"", filename, e);
}
}

Expand Down
Loading