Source code for MSQuant: logger.vb, MSQuant/msquant/src/main/spcommon/logger.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2004 Peter Mortensen and Matthias Mann                     *
'* This file is part of MSQuant.                                            *
'*                                                                          *
'* MSQuant is distributed under the terms of                                *
'* the GNU General Public License. See src/COPYING.TXT or                   *
'* <http://www.gnu.org/licenses/gpl.txt> for details.                       *
'*                                                                          *
'* MSQuant is free software; you can redistribute it                        *
'* and/or modify it under the terms of the GNU                              *
'* General Public License as published by the Free                          *
'* Software Foundation; either version 2 of the                             *
'* License, or (at your option) any later version.                          *
'*                                                                          *
'* MSQuant is distributed in the hope that it will be                       *
'* useful, but WITHOUT ANY WARRANTY; without even the                       *
'* implied warranty of MERCHANTABILITY or FITNESS FOR                       *
'* A PARTICULAR PURPOSE.  See the GNU General Public                        *
'* License for more details.                                                *
'*                                                                          *
'* You should have received a copy of the GNU General                       *
'* Public License along with MSQuant; if not, write to                      *
'* the Free Software Foundation, Inc., 59 Temple                            *
'* Place, Suite 330, Boston, MA  02111-1307  USA                            *
'*                                                                          *
'* Purpose: Holds Class SDUPlogger, see below for documentation.            *
'*                                                                          *
'****************************************************************************

'****************************************************************************
'*                               CEBI                                       *
'*                    Software Development Group                            *
'*                         Peter Mortensen                                  *
'*                E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk          *
'*                 WWW: http://www.cebi.sdu.dk/                             *
'*                                                                          *
'*  Program for post-processing of result from search in mass               *
'*    spectrometric data.                                                   *
'*                                                                          *
'*    FILENAME:   logger.vb                                                 *
'*    TYPE:       VISUAL_BASIC                                              *
'*                                                                          *
'* CREATED: PM 2004-04-14   Vrs 1.0.                                        *
'* UPDATED: PM 2004-xx-xx                                                   *
'*                                                                          *
'****************************************************************************

'Future:
' 1.

Option Strict On
Option Explicit On 

Imports System.Text  'For StringBuilder


'****************************************************************************
'd$ <summary>
'd$   Purpose: Namespace for application independent and domain independent
'd$            utility classes (that could be reused in any application,
'd$            not just mass spectrometric applications.)
'd$   <see cref="T:VBXMLDoc.CVBXMLDoc" />.
'd$   <isUnitTest></isUnitTest>
'd$   <applicationname>XYZ</applicationname>
'd$   <author>Peter Mortensen</author>
'd$   <seealso>http://www.cebi.sdu.dk/</seealso>
'd$   <codetype>PLATFORM independent</codetype>
'd$ </summary>
Namespace SDUPutility

    '****************************************************************************
    'd$ <summary>
    'd$   Purpose:
    'd$     Class to handle loggging activities:
    'd$ 
    'd$       1. Time stamping clients specified events (by a message string)
    'd$       2. Maintenance of the log information
    'd$       3. Dumping to disk
    'd$ 
    'd$   <see cref="T:VBXMLDoc.CVBXMLDoc" />.
    'd$   <applicationname>XYZ</applicationname>
    'd$   <author>Peter Mortensen</author>
    'd$   <seealso>http://www.cebi.sdu.dk/</seealso>
    'd$   <codetype>PLATFORM independent</codetype>
    'd$  'd$  'd$ </summary>
    Public Class SDUPlogger

        Dim mEnableLogging As Boolean

        'Dim mTimeLogArray As String
        Dim mTimeLogArray As StringBuilder

        Dim mTickBase As Integer


        '****************************************************************************
        '*  P U B L I C   S E C T I O N                                             *


        '****************************************************************************
        '*  SUBROUTINE NAME:   New                                                  *
        'd$ <summary>Constructor</summary>
        Public Sub New()
            MyBase.New() 'Is this necessary? Yes!

            mEnableLogging = True
            mTickBase = 0

            'Lazy instantiation
            'Me.resetTimeLog()
            mTimeLogArray = Nothing
        End Sub 'New()


        '****************************************************************************
        '*    <placeholder for header>                                              *
        '****************************************************************************
        Public Sub enableLogging()
            mEnableLogging = True
        End Sub 'enableLogging


        '****************************************************************************
        '*    <placeholder for header>                                              *
        '****************************************************************************
        Public Sub disableLogging()
            mEnableLogging = False
        End Sub 'disableLogging


        '****************************************************************************
        '*  SUBROUTINE NAME: timeLog                                                *
        'd$ <summary>
        'd$   Purpose: xyz.
        'd$   <see cref="T:VBXMLDoc.CVBXMLDoc" />.
        'd$ </summary>
        'd$ <remarks>
        'd$   <para>
        'd$   </para>
        'd$   <para>
        'd$   </para>
        'd$   <seealso cref="E:EnvDTE.BuildEvents.OnBuildDone" /> event. This
        'd$ </remarks>
        Public Sub timeLog(ByVal aMsg As String)

            If mEnableLogging Then 'false: disabled. See also readOutTimeLog().
                If mTimeLogArray Is Nothing Then
                    Me.addHeader()
                End If

                Dim tickCount As Integer = Environment.TickCount
                Dim secs As Double = (tickCount - mTickBase) / 1000.0
                Dim outMsg As String = _
                  secs.ToString("0.000") & ControlChars.Tab & _
                  aMsg & ControlChars.NewLine
                mTimeLogArray.Append(outMsg)

                If outMsg.IndexOf("axControl_setDataObject") >= 0 Then
                    Dim peter2 As Integer = 2
                End If

            End If
        End Sub 'timeLog


        '****************************************************************************
        '*    <placeholder for header>                                              *
        '****************************************************************************
        Public Sub resetTimeLog()

            'Changed PM_MEMORY_ALLOCATION 2004-07-26
            ''mTimeLogArray.Clear()
            'mTimeLogArray = ""
            If mTimeLogArray Is Nothing Then
                mTimeLogArray = New StringBuilder
            End If
            mTimeLogArray.Length = 0

            Me.addHeader()
        End Sub 'resetTimeLog


        '****************************************************************************
        '*    <placeholder for header>                                              *
        '****************************************************************************
        Private Sub addHeader()

            mTickBase = Environment.TickCount
            If mTimeLogArray Is Nothing Then
                mTimeLogArray = New StringBuilder
            End If
            Dim header As String = _
              "Time [secs]" & ControlChars.Tab & _
              "Function/misc" & ControlChars.NewLine
            mTimeLogArray.Append(header)
        End Sub 'addHeader()


        '****************************************************************************
        '*    <placeholder for header>                                              *
        '****************************************************************************
        Public Sub readOutTimeLog()
            If mEnableLogging Then 'See also timeLog().

                'This is not the user so we can set anything we want...
                Dim ex As exportTargetSettingsStruct = _
                  exportTargetSettingsStruct.defaultExportTargetSettings()
                ex.target = targetEnum.enumExportToFile
                ex.filePath = "C:\xyx.txt"
                ex.userAppPath = Nothing

                PILInputOutput.pushToTarget( _
                  mTimeLogArray.ToString, ex, AppCommon2.appPath())
            End If
        End Sub 'readOutTimeLog

    End Class 'SDUPlogger


End Namespace 'SDUPutility


    

    

Generated by script codePublish.pl at 2009-01-05T15:20:59.