01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * 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: * Writes data.
73: */
74: public static void syslog(int facility, int severity, String text) {
75: if (!_isOpen) {
76: _isOpen = true;
77: nativeOpenSyslog();
78: }
79:
80: int priority = facility * 8 + severity;
81:
82: nativeSyslog(priority, text);
83: }
84:
85: private static native void nativeOpenSyslog();
86:
87: private static native void nativeSyslog(int priority, String text);
88:
89: static {
90: try {
91: System.loadLibrary("resin");
92: _hasSyslog = true;
93: } catch (Throwable e) {
94: }
95: }
96: }
|