KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > vfs > Syslog


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.vfs;
30
31 /**
32  * Stream which writes to syslog.
33  */

34 public class Syslog {
35   public static final int LOG_KERN = 0;
36   public static final int LOG_USER = 1;
37   public static final int LOG_MAIL = 2;
38   public static final int LOG_DAEMON = 3;
39   public static final int LOG_AUTH = 4;
40   public static final int LOG_SYSLOG = 5;
41   public static final int LOG_LPR = 6;
42   public static final int LOG_NEWS = 7;
43   public static final int LOG_UUCP = 8;
44   public static final int LOG_CRON = 9;
45   public static final int LOG_AUTHPRIV = 10;
46   public static final int LOG_FTP = 11;
47   public static final int LOG_LOCAL0 = 16;
48   public static final int LOG_LOCAL1 = 17;
49   public static final int LOG_LOCAL2 = 18;
50   public static final int LOG_LOCAL3 = 19;
51   public static final int LOG_LOCAL4 = 20;
52   public static final int LOG_LOCAL5 = 21;
53   public static final int LOG_LOCAL6 = 22;
54   public static final int LOG_LOCAL7 = 23;
55
56   public static final int LOG_EMERG = 0;
57   public static final int LOG_ALERT = 1;
58   public static final int LOG_CRIT = 2;
59   public static final int LOG_ERR = 3;
60   public static final int LOG_WARNING = 4;
61   public static final int LOG_NOTICE = 5;
62   public static final int LOG_INFO = 6;
63   public static final int LOG_DEBUG = 7;
64
65   private static boolean _hasSyslog;
66   private static boolean _isOpen;
67
68   public Syslog()
69   {
70   }
71
72   /**
73    * Writes data.
74    */

75   public static void syslog(int facility, int severity, String JavaDoc text)
76   {
77     if (! _isOpen) {
78       _isOpen = true;
79       nativeOpenSyslog();
80     }
81
82     int priority = facility * 8 + severity;
83
84     nativeSyslog(priority, text);
85   }
86
87   private static native void nativeOpenSyslog();
88
89   private static native void nativeSyslog(int priority, String JavaDoc text);
90
91   static {
92     try {
93       System.loadLibrary("resin");
94       _hasSyslog = true;
95     } catch (Throwable JavaDoc e) {
96     }
97   }
98 }
99
100
Popular Tags