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

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

?? syslog.java

?? Java版syslog實現
?? JAVA
字號:
package com.ice.syslog;

import java.io.*;
import java.net.*;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.text.SimpleDateFormat;

/**
 * The Syslog class implements the UNIX syslog protocol allowing Java
 * to log messages to a specified UNIX host. Care has been taken to
 * preserve as much of the UNIX implementation as possible.
 * <br>
 * To use Syslog, simply create an instance, and use the Syslog() method
 * to log your message. The class provides all the expected syslog constants.
 * For example, LOG_ERR is Syslog.LOG_ERR.
 * <br>
 *
 * Written: <a href="http://www.ice.com/time/">Tim Endres</a><br>
 * Version: 1.2 - July 27, 1998<br>
 * Version: 1.0 - August 14, 1996<br>
 * Source: <a href="http://www.ice.com/java/syslog/index.shtml">Syslog.java</a>
 * @see DatagramSocket
 * @see	InetAddress
 */

public class Syslog extends Object
	{
	// CLASS CONSTANTS

	// CLASS VARIABLES
	
	static private Syslog	logger = null;
	
	// INSTANCE VARIABLES
	
	private String			logName;
	private String			hostName;
	private int				portNum;
	private int				flags;
	private boolean			includeDate;

	private InetAddress		boundAddress;
	private DatagramSocket	socket;

	private SimpleDateFormat	date1Format;
	private SimpleDateFormat	date2Format;


	// CLASS METHODS
	
	/**
	 * Binds the Syslog class to a specified host for further logging.
	 * See the Syslog constructor for details on the parameters.
	 */
	static public void
	open( String hostname, String name, int flags )
		throws SyslogException
		{
		try {
			Syslog.logger =
				new Syslog
					( hostname, SyslogDefs.DEFAULT_PORT, name, flags );
			}
		catch ( SyslogException ex )
			{
			throw ex;
			}
		}
	
	/**
	 * Performs a syslog to the currently bound syslog host.
	 */
	static public void
	log( int fac, int lvl, String msg )
		throws SyslogException
		{
		try {
			logger.syslog( fac, lvl, msg );
			}
		catch ( SyslogException ex )
			{ throw ex; }
		}
	
	/**
	 * Unbinds the current syslog host.
	 */
	static public void
	close()
		{
		logger = null;
		}
	

	/**
	 * Creates a Syslog object instance, targeted for the UNIX host
	 * with the hostname 'hostname' on the syslog port 'port'.
	 * The only flags recognized are 'LOG_PERROR', which will log the
	 * message to Java's 'System.err'.
	 */
	public
	Syslog( String name, int flags )
		throws SyslogException
		{
		super();
		
		this.logName = name;
		this.hostName = null;
		this.portNum = SyslogDefs.DEFAULT_PORT;
		this.flags = flags;

		this.initialize();
		}
		
	/**
	 * Creates a Syslog object instance, targeted for the UNIX host
	 * with the hostname 'hostname' on the syslog port 'port'.
	 * The only flags recognized are 'LOG_PERROR', which will log the
	 * message to Java's 'System.err'.
	 */
	public
	Syslog( String hostname, int port, String name, int flags )
		throws SyslogException
		{
		super();
		
		this.logName = name;
		this.hostName = hostname;
		this.portNum = port;
		this.flags = flags;

		try {
			this.boundAddress = InetAddress.getByName( hostname );
			}
		catch ( UnknownHostException ex )
			{
			String message =
				"error locating host named '" + hostname
					+ "': " + ex.getMessage();
			
			throw new SyslogException( message );
			}

		this.initialize();
		}
	
	private void
	initialize()
		throws SyslogException
		{
		try {
			this.socket = new DatagramSocket();
			}
		catch ( SocketException ex )
			{
			String message =
				"error creating syslog udp socket: "
					+ ex.getMessage();

			throw new SyslogException( message );
			}

		// This determines if the timestamp is added to the message
		// in this, the client, or if it is left off for the server
		// to fill in. Adding it in the client is the "standard" way,
		// but most servers support the "old style" (no timestamp)
		// messages as well. I leave this choice, since some servers
		// may not work without it, and because some JDK's may not
		// support SimpleDateFormat or TimeZone correctly.

		this.includeDate = true;

		if ( this.includeDate )
			{
			// We need two separate formatters here, since there is
			// no way to get the single digit date (day of month) to
			// pad with a space instead of a zero.
			this.date1Format =
				new SimpleDateFormat
					( "MMM  d HH:mm:ss ", Locale.US );

			this.date2Format =
				new SimpleDateFormat
					( "MMM dd HH:mm:ss ", Locale.US );

			this.date1Format.setTimeZone
				( TimeZone.getDefault() );

			this.date2Format.setTimeZone
				( TimeZone.getDefault() );
			}
		}

	/**
	 * Use this method to log your syslog messages. The facility and
	 * level are the same as their UNIX counterparts, and the Syslog
	 * class provides constants for these fields. The msg is what is
	 * actually logged.
	 */
	public void
	syslog( int fac, int pri, String msg )
		throws SyslogException
		{
		this.syslog( this.boundAddress, this.portNum, fac, pri, msg );
		}

	/**
	 * Use this method to log your syslog messages. The facility and
	 * level are the same as their UNIX counterparts, and the Syslog
	 * class provides constants for these fields. The msg is what is
	 * actually logged.
	 */
	public void
	syslog( InetAddress addr, int fac, int pri, String msg )
		throws SyslogException
		{
		this.syslog( addr, this.portNum, fac, pri, msg );
		}

	/**
	 * Use this method to log your syslog messages. The facility and
	 * level are the same as their UNIX counterparts, and the Syslog
	 * class provides constants for these fields. The msg is what is
	 * actually logged.
	 */
	public void
	syslog( String hostname, int fac, int pri, String msg )
		throws SyslogException
		{
		try {
			InetAddress address = InetAddress.getByName( hostname );
			this.syslog( address, this.portNum, fac, pri, msg );
			}
		catch ( UnknownHostException ex )
			{
			String message =
				"error locating host named '" + hostname
					+ "': " + ex.getMessage();
			
			throw new SyslogException( message );
			}
		}

	/**
	 * Use this method to log your syslog messages. The facility and
	 * level are the same as their UNIX counterparts, and the Syslog
	 * class provides constants for these fields. The msg is what is
	 * actually logged.
	 */
	public void
	syslog( String hostname, int port, int fac, int pri, String msg )
		throws SyslogException
		{
		try {
			InetAddress address = InetAddress.getByName( hostname );
			this.syslog( address, port, fac, pri, msg );
			}
		catch ( UnknownHostException ex )
			{
			String message =
				"error locating host named '" + hostname
					+ "': " + ex.getMessage();
			
			throw new SyslogException( message );
			}
		}

	/**
	 * Use this method to log your syslog messages. The facility and
	 * level are the same as their UNIX counterparts, and the Syslog
	 * class provides constants for these fields. The msg is what is
	 * actually logged.
	 */
	public void
	syslog( InetAddress addr, int port, int fac, int pri, String msg )
		throws SyslogException
		{
		int				pricode;
		int				length;
		int				idx, sidx, nidx;
		StringBuffer	buffer;
		byte[]			data;
		byte[]			sBytes;
		byte[]			numbuf = new byte[32];
		String			nmObj;
		String			strObj;
		
		pricode = SyslogDefs.computeCode( fac, pri );
		Integer priObj = new Integer( pricode );
		
		if ( this.logName != null )
			{
			nmObj = new String( this.logName );
			}
		else
			{
			nmObj = new String( Thread.currentThread().getName() );
			}

		length = 4 + nmObj.length() + msg.length() + 1;
		length += (pricode > 99) ? 3 : ( (pricode > 9) ? 2 : 1 );

		String dStr = null;
		if ( this.includeDate )
			{
			// See note above on why we have two formats...
			Calendar now = Calendar.getInstance();
			if ( now.get( Calendar.DAY_OF_MONTH ) < 10 )
				dStr = this.date1Format.format( now.getTime() );
			else
				dStr = this.date2Format.format( now.getTime() );

			length += dStr.length();
			}

		data = new byte[length];
		
		idx = 0;
		data[idx++] = '<';
		
		strObj = priObj.toString( priObj.intValue() );
		sBytes = strObj.getBytes();
		System.arraycopy
			( sBytes, 0, data, idx, sBytes.length );
		idx += sBytes.length;
		
		data[idx++] = '>';

		if ( this.includeDate )
			{
			sBytes = dStr.getBytes();
			System.arraycopy
				( sBytes, 0, data, idx, sBytes.length );
			idx += sBytes.length;
			}

		sBytes = nmObj.getBytes();
		System.arraycopy
			( sBytes, 0, data, idx, sBytes.length );
		idx += sBytes.length;
		
		data[idx++] = ':';
		data[idx++] = ' ';

		sBytes = msg.getBytes();
		System.arraycopy
			( sBytes, 0, data, idx, sBytes.length );
		idx += sBytes.length;
		
		data[idx] = 0;

		DatagramPacket packet =
			new DatagramPacket( data, length, addr, port );
		
		try {
			socket.send( packet );
			}
		catch ( IOException ex )
			{
			String message =
				"error sending message: '" + ex.getMessage() + "'";

			System.err.println( message );
			throw new SyslogException( message );
			}

		if ( (this.flags & SyslogDefs.LOG_PERROR) != 0 )
			{
			if ( this.logName != null )
				{
				System.err.print( this.logName + ": " );
				}
			else
				{
				System.err.print
					( Thread.currentThread().getName() + ": " );
				}

			System.err.println( msg );
			}
		}
	}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一二三四| 在线一区二区三区四区五区| 精品一区二区三区视频 | 97se亚洲国产综合自在线不卡| www国产成人| 国产盗摄一区二区| 日韩三级视频在线观看| 国产美女久久久久| 一区二区三区小说| 欧美日韩在线播放三区| 精品亚洲国产成人av制服丝袜| 久久国产婷婷国产香蕉| 亚洲欧洲国产日韩| 精品国产凹凸成av人网站| 中文字幕不卡在线播放| 亚洲电影激情视频网站| 精品国产一区二区精华| 欧美日韩国产综合一区二区 | 亚洲精品久久嫩草网站秘色| 国产91在线观看| 91成人在线精品| 91丨porny丨国产入口| 久久综合九色综合97_久久久| 777精品伊人久久久久大香线蕉| 国产一区亚洲一区| 国产一区二区按摩在线观看| 国产又粗又猛又爽又黄91精品| 国内精品国产成人| 中文字幕亚洲不卡| 亚洲欧洲国产日韩| 国产精品色哟哟| 一本色道久久综合狠狠躁的推荐| 国产日韩精品一区二区三区在线| 卡一卡二国产精品 | 偷拍亚洲欧洲综合| 日韩有码一区二区三区| 男人操女人的视频在线观看欧美| 免费人成精品欧美精品| 国产成人小视频| 色综合视频在线观看| 欧美色图一区二区三区| 强制捆绑调教一区二区| 狠狠狠色丁香婷婷综合久久五月| 成人综合日日夜夜| 日本不卡一二三区黄网| 国产成人啪午夜精品网站男同| av一区二区三区黑人| 精品系列免费在线观看| 成人丝袜视频网| 欧美三日本三级三级在线播放| 精品黑人一区二区三区久久 | 中文字幕成人在线观看| 亚洲午夜羞羞片| 久久99最新地址| 91福利国产精品| 久久久噜噜噜久久人人看 | 激情综合网激情| 夫妻av一区二区| 这里只有精品99re| 中文字幕免费观看一区| ●精品国产综合乱码久久久久| 日本欧美大码aⅴ在线播放| 日韩一区二区三区精品视频| 久久久久88色偷偷免费| 亚洲sss视频在线视频| 国产宾馆实践打屁股91| 制服丝袜亚洲精品中文字幕| 国产精品久久久久久亚洲毛片| 日韩成人dvd| 色狠狠桃花综合| 亚洲国产精品传媒在线观看| 麻豆免费看一区二区三区| 日本免费新一区视频| 日本韩国一区二区三区| 国产亚洲欧美激情| 精品国产百合女同互慰| 亚洲va在线va天堂| 欧美在线你懂的| 国产精品久久久久久久蜜臀| 国产一区91精品张津瑜| 欧美一级专区免费大片| 日韩精品一区二区三区视频| 一区二区三区中文免费| 成人一区二区三区在线观看| 欧美剧在线免费观看网站| 欧美一区二区女人| 亚洲香肠在线观看| 欧美日韩国产免费| 亚洲高清免费在线| 欧美性淫爽ww久久久久无| 亚洲欧美日韩久久精品| 色一情一伦一子一伦一区| 中文字幕一区二| 成人av在线影院| 国产成人在线免费观看| 欧美xxxx老人做受| 亚洲精品成人少妇| av在线综合网| 国产亚洲福利社区一区| 国产精品一二三区| 久久精品综合网| 暴力调教一区二区三区| 亚洲欧美日韩国产综合在线| 色婷婷激情综合| 日本亚洲电影天堂| 日韩欧美国产wwwww| 精品在线视频一区| 国产亚洲精品超碰| 国产不卡视频一区二区三区| 亚洲欧美另类久久久精品| 在线视频国产一区| 日韩av网站在线观看| 亚洲精品在线电影| 成人v精品蜜桃久久一区| 中文字幕免费不卡在线| 91色视频在线| 久久er精品视频| 欧美激情在线观看视频免费| 99久久综合精品| 日韩中文字幕麻豆| 精品成人在线观看| 色欧美88888久久久久久影院| 亚洲第一主播视频| 精品电影一区二区| 91福利在线播放| 九九热在线视频观看这里只有精品 | 国产精品久久看| 91伊人久久大香线蕉| 亚洲一区二区三区四区在线免费观看| 精品久久久久一区二区国产| 韩国一区二区视频| 亚洲一区在线观看免费观看电影高清| 欧美xxxxxxxxx| 一本大道久久a久久综合婷婷| 美国十次综合导航| 亚洲女同一区二区| 欧美成人高清电影在线| 色屁屁一区二区| 国产成人免费xxxxxxxx| 亚洲va中文字幕| 亚洲欧洲国产日韩| 久久免费电影网| 欧美一区三区二区| 色综合久久九月婷婷色综合| 国内精品伊人久久久久影院对白| 国产精品久久久一区麻豆最新章节| 91精品国产综合久久福利 | 国产精品美女久久久久久久久久久| 欧美日本在线播放| 91视频观看视频| 成人免费高清在线| 精品一区二区三区日韩| 午夜激情一区二区三区| 中文字幕一区在线观看视频| 久久新电视剧免费观看| 欧美高清视频不卡网| 91一区二区在线观看| 精品影视av免费| 九九国产精品视频| 久久99久久久欧美国产| 亚洲小少妇裸体bbw| 亚洲最新在线观看| 亚洲精品视频在线| 亚洲免费电影在线| 中文字幕色av一区二区三区| 国产色爱av资源综合区| 欧美电影免费观看完整版| 在线不卡a资源高清| 欧美日韩亚洲综合一区| 91黄色免费观看| 国产精品一区二区三区网站| 麻豆专区一区二区三区四区五区| 国产一区二区三区日韩| 国产乱子伦视频一区二区三区| 精品亚洲成a人| 国产一级精品在线| 国产成人在线视频免费播放| 国产福利一区二区三区| 国产美女久久久久| 国产一区二区三区四区五区美女| 另类中文字幕网| 国产精品一区一区| 成人免费视频国产在线观看| 成人听书哪个软件好| 91啪九色porn原创视频在线观看| 99久久久免费精品国产一区二区| 99热国产精品| 欧美午夜影院一区| 欧美猛男超大videosgay| 51精品秘密在线观看| 日韩精品一区二区三区在线观看| 久久综合99re88久久爱| 精品三级在线看| 国产色产综合产在线视频| 亚洲主播在线观看| 精品一区二区三区在线观看| 9人人澡人人爽人人精品| 欧洲一区二区三区在线| 日韩精品一区二区三区蜜臀| 国产精品沙发午睡系列990531|