亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? logger.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? JAVA
字號:
/*****************************************************************
JADE - Java Agent DEvelopment Framework is a framework to develop 
multi-agent systems in compliance with the FIPA specifications.
Copyright (C) 2000 CSELT S.p.A. 

GNU Lesser General Public License

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, 
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA  02111-1307, USA.
*****************************************************************/
package examples.PingAgent;

import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;

import java.io.*;
import java.text.SimpleDateFormat;

/**
This class implements a Logger. It can be used to log the messages exchanged by agents.
The log message can be of the format:
 
A new log file is created every week.
The log maintain information using this format:
<ul>
<li> <b> GUID - - [Date]   "[TX/RX] Performative"</b> where: 
<ul> <li> GUID is the sender agent of the message received or the receiver of the message for a sent message. 
     <li> the Date when the log message has been write
     <li> TX or RX :TX for a transmitted, RX for a received message.
     <li> Perfomative: the performative received or sent. 
</ul>
<li> <b>  GUID - - [Date]   "TX/RX Performative" fullMsg </b> where the format is the same as the previous but it's possible to write the full message exchanged.
<li> <b> [Date] RX/TX ACLMessage/Perfomative </b> : if no Agent has to be specified.
<li><b>   [Date] text </b>: to write whatever log message.
</ul>

@author Tiziana Trucco - Tilab S.p.A.
@version  $Date: 2002-08-02 10:09:39 +0200 (ven, 02 ago 2002) $ $Revision: 3319 $  
*/

public class Logger {

    //static variable to use for the log messages.
    /*
      Static variables to be used as constant for the TX/RX symbols
     */
    public static final String RECEIVED = "RX";
    /*
      Static variables to be used as constant for the TX/RX symbols
    */
    public static final String TRANSMITTED = "TX";

 
    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy_MM_dd");
    SimpleDateFormat logDateFormatter = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss"); //FIXME: non ho trattato il time zone.
    PrintWriter writer;
    boolean justCreated;
    String fileName;
    Date fileCreationDate;

    /**
      Creates a new Logger. The name of the log file will be: fileName.log
      Pay attention that the extension .log is added at the end of the fileName.
    */
    public Logger(String fileName){
	try{
	    this.fileName = fileName + ".log";
	    fileCreationDate = new Date();
	    writer = new PrintWriter(new FileWriter(this.fileName,true));
	    justCreated = true;	
	}catch(IOException ex){
	    ex.printStackTrace();
	}
    }


    /**
       Use this method to write message into the log file with this format:
       GUID - - [Date]   "[TX/RX] Performative"
       where GUID is the sender for a RX message, or the receiver for a TX message. 
       Format of Apache logs: 163.162.130.24 - - [14/Jan/2002:17:07:11 +0100] "GET / HTTP/1.1" 200 1494
       It canalso be used to write the full message when it nto possible to know the performative.
     */
    public synchronized void log(String GUID, String kind,  String performative){

	// verify if create a new file.
	checkFileLog();
	String format = logDateFormatter.format(new Date());
	String logMsg = GUID + " - - " +"["+ format + "] " + "\"" + kind + " " + performative + "\"";
	writer.println(logMsg);  
	writer.flush();
    }

    /*
      Use this method when you want to write a more complete message in case of error.
      GUID - - [Date]   "TX/RX Performative" fullMsg
The same as previous <code>log</code> but the full message in this case is written.
     */
    public synchronized void log(String GUID, String kind,String performative, String fullMsg){
	// verify if create a new file.
	checkFileLog();
	String format = logDateFormatter.format(new Date());
	String logMsg = GUID + " - - " +"["+ format + "] " + "\"" + kind + " " + performative + "\" " + fullMsg;
	writer.println(logMsg);  
	writer.flush();
    }

    /**
       This method write a message using this format:
       [Date] RX/TX FullMessage/Perfomative.
       No sender o receiver specified
     */
    public synchronized void log(String kind,String message){
	checkFileLog();
	String format = logDateFormatter.format(new Date());
	String logMsg = "[" + format +"] " + kind + " " + message;
	writer.println(logMsg);
	writer.flush();
    }

    /**
       This method write a message using this format:
       [Date] text.
     */
    public synchronized void log(String text){
	checkFileLog();
	String format = logDateFormatter.format(new Date());
	String logMsg = "[" + format +"] " + text;
	writer.println(logMsg);
	writer.flush();
    }

   
    
    //verify if the log file is old so close the old one and rename it. create a new file every sunday.
    //note that if no message was written on sunday no new file will be created.
    private void checkFileLog(){
	
	Calendar today = Calendar.getInstance();
	if(today.get(Calendar.DAY_OF_WEEK) == 1){
	    if(!justCreated ){ //create a new file every SUNDAY only if not already created.
		//create a new file
		justCreated = true;
		writer.close();
		try{
		    //rename the file appends the current date.
		    File ff = new File(this.fileName);
		    ff.renameTo(new File(renameFile()));
		 
		    writer =  new PrintWriter(new FileWriter(this.fileName,true));
		   
		}catch(IOException ex){ 
		    ex.printStackTrace();
		}
	    }
	}else{
	    justCreated = false;
	}
    }
 
   

    //return the new name for archive the old log file. The is added as suffix to the previous name.
    private String renameFile(){
	String format = dateFormatter.format(fileCreationDate);
       
	int ext_index = fileName.indexOf(".log");

	String ext = ".log";
	String newName = fileName.substring(0,ext_index);	    
       
	newName += "_" + format + ext;
	fileCreationDate = new Date();
	return newName;
	    
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产网红主播福利一区二区| 自拍av一区二区三区| 国产91精品在线观看| av亚洲精华国产精华精| 91久久精品午夜一区二区| 久久久久久免费网| 亚洲精品欧美专区| 喷水一区二区三区| 成人综合在线网站| 日韩一区二区精品在线观看| 亚洲欧洲精品一区二区精品久久久 | 经典一区二区三区| 不卡一区中文字幕| 日韩免费在线观看| 日韩毛片精品高清免费| 日本亚洲欧美天堂免费| 国产成人精品网址| 欧美成人伊人久久综合网| 亚洲欧美另类小说视频| 国产一区在线观看麻豆| 欧美体内she精视频| 在线播放欧美女士性生活| 中文字幕综合网| 国产乱人伦偷精品视频免下载| 欧美综合色免费| 中文字幕中文字幕中文字幕亚洲无线| 日韩精品成人一区二区三区| 91年精品国产| 国产精品久久久久久久裸模 | 精品黑人一区二区三区久久| 亚洲影院久久精品| 97久久精品人人爽人人爽蜜臀 | www.66久久| 久久新电视剧免费观看| 日本一不卡视频| 欧美日韩一区二区在线观看 | 日韩一区二区免费视频| 一二三四区精品视频| 国产一区啦啦啦在线观看| 国产精品自在在线| 欧美xxxx老人做受| 婷婷综合五月天| 欧日韩精品视频| 亚洲女厕所小便bbb| 成人免费毛片a| 91精品国产入口| 日韩福利电影在线观看| 欧美日韩日本视频| 亚洲成人自拍一区| 欧美日韩综合在线| 一区二区三区在线视频免费| www.色精品| 国产精品麻豆久久久| 丁香啪啪综合成人亚洲小说| 欧美大片一区二区| 精品在线免费视频| 久久综合久久鬼色| 国产河南妇女毛片精品久久久| 国产欧美一区视频| 床上的激情91.| 成人免费在线视频| 国产69精品久久久久毛片 | 91在线精品秘密一区二区| 中文字幕在线一区免费| 色综合久久99| 亚洲一区二区不卡免费| 欧美乱熟臀69xxxxxx| 99综合电影在线视频| 欧美激情一二三区| 92精品国产成人观看免费| 亚洲日本在线天堂| 欧美日韩免费高清一区色橹橹 | 日韩一级黄色片| 国产在线精品视频| 国产欧美一区二区精品久导航| 伦理电影国产精品| 国产日韩欧美不卡在线| 成人av高清在线| 亚洲码国产岛国毛片在线| 欧美日韩亚洲国产综合| 六月婷婷色综合| 欧美国产一区二区| 日本精品裸体写真集在线观看 | 7777精品伊人久久久大香线蕉超级流畅 | 国产福利91精品一区| 国产精品久久久久久久第一福利 | 美洲天堂一区二卡三卡四卡视频 | 欧美男男青年gay1069videost | 国产一区二区三区久久久| 欧美精品日韩一区| 国产成人一区二区精品非洲| 一区二区三区欧美亚洲| 欧美成人猛片aaaaaaa| 91在线观看美女| 国内不卡的二区三区中文字幕| 亚洲欧洲性图库| 日韩久久免费av| 色综合久久99| 国产成人午夜精品影院观看视频 | 亚洲一卡二卡三卡四卡| 久久女同精品一区二区| 欧美羞羞免费网站| 亚洲夂夂婷婷色拍ww47| 久久综合久久综合九色| 欧美在线免费播放| 粉嫩aⅴ一区二区三区四区| 日日夜夜一区二区| 亚洲欧美另类在线| 日本一区二区三级电影在线观看| 欧美久久久一区| 97aⅴ精品视频一二三区| 韩国成人精品a∨在线观看| 亚洲综合色网站| 国产精品久久久一区麻豆最新章节| 亚洲成人av免费| 国产精品久久影院| www国产成人免费观看视频 深夜成人网 | 中文字幕视频一区| 久久嫩草精品久久久久| 欧美日韩国产大片| 成人看片黄a免费看在线| 毛片av一区二区| 亚洲成人在线观看视频| 国产精品国产三级国产普通话蜜臀 | 欧美精品丝袜久久久中文字幕| 成人18精品视频| 国产麻豆精品在线观看| 欧美aaaaaa午夜精品| 亚洲一级在线观看| 亚洲狼人国产精品| 一区免费观看视频| 国产欧美一区二区精品性色超碰| 日韩欧美一级在线播放| 欧美日韩亚洲另类| 欧美少妇xxx| 91久久精品一区二区三| 97久久精品人人做人人爽50路| 国产成人免费9x9x人网站视频| 免费成人性网站| 全国精品久久少妇| 日日夜夜精品视频天天综合网| 亚洲午夜在线电影| 一区二区成人在线| 亚洲最大色网站| 亚洲一区二区av在线| 亚洲国产日韩一级| 亚洲一区二区三区四区五区中文| 亚洲激情在线播放| 亚洲猫色日本管| 一区二区三区电影在线播| 亚洲人成网站影音先锋播放| 综合分类小说区另类春色亚洲小说欧美| 国产精品素人视频| 亚洲欧洲av另类| 亚洲精品成人在线| 亚洲综合免费观看高清完整版在线 | 欧美猛男男办公室激情| 欧美日韩国产在线观看| 在线播放欧美女士性生活| 51久久夜色精品国产麻豆| 91精品婷婷国产综合久久性色| 欧美精品自拍偷拍| 日韩亚洲欧美高清| 日韩一区二区在线观看视频播放| 91视频在线观看免费| 亚洲天堂中文字幕| 久久免费美女视频| 色噜噜狠狠一区二区三区果冻| 亚洲一区在线视频观看| 欧美一区二区视频免费观看| 激情综合五月婷婷| 成人免费在线视频观看| 欧美亚洲图片小说| 欧美午夜精品久久久| 亚洲国产综合人成综合网站| 91精品国产高清一区二区三区蜜臀 | 亚洲色图色小说| 亚洲美女偷拍久久| 偷拍与自拍一区| 麻豆91免费观看| 国产精品一区免费视频| 风流少妇一区二区| 色噜噜狠狠成人中文综合| 欧美裸体bbwbbwbbw| 精品88久久久久88久久久| 国产精品美女久久久久高潮| 亚洲乱码国产乱码精品精98午夜| 亚洲无人区一区| 麻豆极品一区二区三区| 成人免费看视频| 欧美色欧美亚洲另类二区| 日韩欧美国产电影| 一色桃子久久精品亚洲| 午夜精品久久久久久久99水蜜桃 | 亚洲欧美中日韩| 天天色综合天天| 又紧又大又爽精品一区二区| 亚洲成人午夜电影| 国产精品一区二区三区网站| 91蜜桃网址入口|