コード例 #1
0
        /// <summary> Constructs a StreamMsgLogger that uses 'outstr' as the 'out' stream,
        /// and 'errstr' as the 'err' stream. Note that 'outstr' and 'errstr' can
        /// be System.out and System.err.
        ///
        /// </summary>
        /// <param name="outstr">Where to print simple strings and LOG and INFO messages.
        ///
        /// </param>
        /// <param name="errstr">Where to print WARNING and ERROR messages
        ///
        /// </param>
        /// <param name="lw">The line width to use in formatting
        ///
        ///
        ///
        /// </param>
        ///

        /*
         *      public StreamMsgLogger(System.IO.StreamWriter outstr, System.IO.StreamWriter errstr, int lw)
         *      {
         *              out_Renamed = outstr;
         *              err = errstr;
         *              mp = new MsgPrinter(lw);
         *      }
         */
        /// <summary> Prints the message 'msg' to the output device, appending a newline,
        /// with severity 'sev'. The severity of the message is prepended to the
        /// message.
        ///
        /// </summary>
        /// <param name="sev">The message severity (LOG, INFO, etc.)
        ///
        /// </param>
        /// <param name="msg">The message to display
        ///
        ///
        ///
        /// </param>
        public virtual void printmsg(int sev, System.String msg)
        {
            System.IO.StreamWriter lout;
            //int ind;
            System.String prefix;

            switch (sev)
            {
            case CSJ2K.j2k.util.MsgLogger_Fields.LOG:
                prefix = "[LOG]: ";
                lout   = out_Renamed;
                break;

            case CSJ2K.j2k.util.MsgLogger_Fields.INFO:
                prefix = "[INFO]: ";
                lout   = out_Renamed;
                break;

            case CSJ2K.j2k.util.MsgLogger_Fields.WARNING:
                prefix = "[WARNING]: ";
                lout   = err;
                break;

            case CSJ2K.j2k.util.MsgLogger_Fields.ERROR:
                prefix = "[ERROR]: ";
                lout   = err;
                break;

            default:
                throw new System.ArgumentException("Severity " + sev + " not valid.");
            }

            mp.print(lout, 0, prefix.Length, prefix + msg);
            lout.Flush();
        }