001: /**********************************************************************************
002: * $URL: $
003: * $Id: $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.component.osid.logging;
021:
022: /**
023: *
024: * @inheritDoc
025: *
026: */
027: public class LoggingManager implements org.osid.logging.LoggingManager {
028: org.osid.OsidContext context = null;
029: java.util.Properties configuration = null;
030: private org.osid.shared.Type plainLoggingFormatType = new Type(
031: "sakaiproject.org", "log", "plain", "Plain Logging Type");
032: private org.osid.shared.Type infoLoggingPriorityType = new Type(
033: "sakaiproject.org", "log", "priority", "Plain Logging Type");
034: private java.io.PrintWriter writeFile;
035: private String fileExtension = null;
036:
037: public org.osid.OsidContext getOsidContext()
038: throws org.osid.logging.LoggingException {
039: return context;
040: }
041:
042: public void assignOsidContext(org.osid.OsidContext context)
043: throws org.osid.logging.LoggingException {
044: this .context = context;
045: }
046:
047: public void assignConfiguration(java.util.Properties configuration)
048: throws org.osid.logging.LoggingException {
049: this .configuration = configuration;
050: }
051:
052: public void initialize() throws org.osid.logging.LoggingException {
053: }
054:
055: public org.osid.shared.TypeIterator getFormatTypes()
056: throws org.osid.logging.LoggingException {
057: java.util.Vector vector = new java.util.Vector();
058: vector.addElement(plainLoggingFormatType);
059: try {
060: return (new TypeIterator(vector));
061: } catch (org.osid.shared.SharedException sex) {
062: throw new org.osid.logging.LoggingException(
063: org.osid.logging.LoggingException.OPERATION_FAILED);
064: }
065: }
066:
067: public org.osid.shared.TypeIterator getPriorityTypes()
068: throws org.osid.logging.LoggingException {
069: java.util.Vector vector = new java.util.Vector();
070: vector.addElement(infoLoggingPriorityType);
071: try {
072: return (new TypeIterator(vector));
073: } catch (org.osid.shared.SharedException sex) {
074: throw new org.osid.logging.LoggingException(
075: org.osid.logging.LoggingException.OPERATION_FAILED);
076: }
077: }
078:
079: public org.osid.shared.StringIterator getLogNamesForWriting()
080: throws org.osid.logging.LoggingException {
081: initialize();
082: java.util.Vector v = new java.util.Vector();
083:
084: v.addElement("trace");
085: v.addElement("debug");
086: v.addElement("info");
087: v.addElement("warn");
088: v.addElement("error");
089: v.addElement("fatal");
090:
091: try {
092: return (new StringIterator(v));
093: } catch (org.osid.shared.SharedException sex) {
094: throw new org.osid.logging.LoggingException(
095: org.osid.logging.LoggingException.OPERATION_FAILED);
096: }
097: }
098:
099: public org.osid.logging.WritableLog createLog(String logName)
100: throws org.osid.logging.LoggingException {
101: if (logName == null) {
102: throw new org.osid.logging.LoggingException(
103: org.osid.logging.LoggingException.NULL_ARGUMENT);
104: }
105: return (new WritableLog(context, configuration, logName));
106: }
107:
108: public void deleteLog(String logName)
109: throws org.osid.logging.LoggingException {
110: if (logName == null) {
111: throw new org.osid.logging.LoggingException(
112: org.osid.logging.LoggingException.NULL_ARGUMENT);
113: }
114: }
115:
116: public org.osid.logging.WritableLog getLogForWriting(String logName)
117: throws org.osid.logging.LoggingException {
118: if (logName == null) {
119: throw new org.osid.logging.LoggingException(
120: org.osid.logging.LoggingException.NULL_ARGUMENT);
121: }
122: return (new WritableLog(context, configuration, logName));
123: }
124:
125: // No logs are currently readable
126: public org.osid.shared.StringIterator getLogNamesForReading()
127: throws org.osid.logging.LoggingException {
128: throw new org.osid.logging.LoggingException(
129: org.osid.logging.LoggingException.OPERATION_FAILED);
130: }
131:
132: public org.osid.logging.ReadableLog getLogForReading(String logName)
133: throws org.osid.logging.LoggingException {
134: throw new org.osid.logging.LoggingException(
135: org.osid.logging.LoggingException.OPERATION_FAILED);
136: }
137:
138: public boolean supportsReading()
139: throws org.osid.logging.LoggingException {
140: return true;
141: }
142:
143: public void osidVersion_2_0()
144: throws org.osid.logging.LoggingException {
145: }
146: }
|