SasLogMessage.java
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:1k
- /* $Id: SasLogMessage.java,v 1.3 2002/09/09 05:48:54 parasuraman Exp $ */
- /*
- * @(#)SasLogMessage.java
- * Copyright (c) 1996-2002 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- import java.io.*;
- import java.util.*;
- import java.awt.*;
- import java.lang.*;
- import com.adventnet.snmp.sas.*;
- /** SasLogMessage implements SasLogInterface
- * Users can implement their own Log Message
- * Everytime the log messages are appended into a file.
- * This will create files Debug,Out,Error.
- * This class can be used with SAServer with -log_class option. See the
- * documentation for more details on the options.
- * Usage : java com.adventnet.snmp.sas.SAServer -log_class SasLogMessage
- */
- public class SasLogMessage implements SasLogInterface {
-
- public void dbg(String dbg) {
-
- appendFile(dbg, "Debug");
- }
- public void out(String out) {
-
- appendFile(out, "Out");
- }
-
- public void err(String err) {
-
- appendFile(err, "Error");
- }
-
- private synchronized void appendFile(String s, String fname) {
-
- String filename = fname;
- FileWriter fs;
- try {
- fs = new FileWriter(filename, true);
- String s1 = s+"n";
- fs.write(s1, 0, s1.length());
- fs.close();
- } catch (Exception ie) {
- System.err.println("Error writing to: "+filename+":"+ie);
- ie.printStackTrace();
- }
- } // end appendFile()
- }