You are on page 1of 4
Doe pe Tech Notes Doct suao0022272 Legacy Doc it rio abi Oto 2ana01s Logging Messages to ArchestrA Logger Using Toolkit API Functions. PROBLEM Title Logaing Messages to ArchestrA Logger Using Took API Functions. SOLUTION ‘Summary This isa Micrasof Visual Basic® Demo Application to demonstrate the use of AI unction that write debug messages to ArchestrA Logger under the default and custom LogFlag categories, The same can be used in an IDEA Tookil application or a TagAccess Tookkit Applicaton tat is developed using Visual Basic 6 0. Note: Microsoft Visual Basic Version 6 0 SP5 is used to develop this demo application. This application uses FSLogger bas module that cores with the instalation of toolkits from ArchestrA Toolkit CD. The defaut location of FSLogger bas is in folder ..\Program Files\ArchestrA\Toolkitsline\Logger\. The IDEA Toolkit and TagAccess Tookit can be installed trom InTouch® Extensibility Toolat v7.11 Situation Download the Sample Executable ‘Dowinload the sample executable (Attached). ‘Setup Steps for Using Logger: Incuce the module FSLogger bas (C:\Program Files\ArchestrAlToolkits\inc\L ogger) in your project. Make sure Logger is instaled on the node and the PATH environment variable includes the patho LeggerDLL dll (This s usualy C:\Program files\Common flles\Archestra) Logger Functions: “The FSLogget bas module declares a set of unctions that can be used for sending various categories of messages to the FSLogger service. The followang functions can be used for logging the pre-defined categones of messages: [Logerror ke, ‘an error message, ior messages are used to indicate an err “andition from which you cannot continue. [Cogwarning ‘09 a warring message. fing messages are used to indicate an etror ‘ondition from which you can continue, but te output nay nol be what was desired. ICoginto ‘0g an informational message vo messages simply describe successful completion] large tasks, or other thngs thal may be of casual ricrest to the user (LogTrace [Loga generic race message. ‘ogStartStop Log that some component has Slated or Stopped [These messages can help in showing when ceriain facesses or abjects have been started or shut down. ‘ogThreadStartStopl. og that a toad has slatted or stopped CHS ENAGup esl Ads ene AVEVA pogsur, og Sur retatea messages hese messages canbe used for things like dumping (QL select strings that are too ong to be viewed in 2 Developer Sudo debugaer [CagRefCount fon abject reference counts [CegEntrExit flog afincion enyent message hese messages simply flag that functions have been tered and exited [CegConnection ona comocion message [LegCtorDter og a ConsivctorDesiuciormessaoe “The FSLoggerbas module declares a set offunct Using the Functions Allthe LogXXXX functions have similar syntax. They take a sting parameter, which identifies the message to be logged. The following example ‘shows how fo pass a simple string to the logger as an error message LLogError "This is an error that should be reported Loginfo “This is an information to the user’ Figure T- Log Viewer Enmies, Logging Custom Messages In adltion tothe pre-defined categories of massages, i your component naeds to log messages belonging to @ custom category, it can be done sing the folowing steps 1. Use the function LogRegisterCustomFlag to define your on custom message type and register it withthe Logger bim Cookie as long cookie = LogRogisterCustomFlag (*Pexs0ata") ‘The parameter is a sting that specifies he name using which the custom category will be identinied “The function returns a cookie, which can then be used to refer tothe custom category in other Logger functons, 2. Use the tunction LogCustom to log messages under this custom category The usage ofthis function s similar tothe functions ike LogE tro, LogWarning ete, except that the fst parameter isthe cockie that was returned by the LegRegisterCustomFlag function, Cockie, "This is a custom message" Legcus LogCustom Cockie, “the operation tock $0 seconds* Note: The PerfData Giobal Log Flag must be selected before you can view the messages in the logger (Figure 2 below). 015 SEA sid 8s ee AVEVA ‘Tenns of Use Privacy Policy Ce 8 [= Sevare= ied z Fr (a er Bg emcenn me Coens or acto Irae a a retarecerns Bgprerernancin Arr maciintiron | DS trom:noany OF rstiemasts OF Frecesstenitaibte Figure 3. Log Enty Registering a Custom Flag with a Default Value \When a custom lag is registered by using the LogRegisterCustomFiag function, the defaut valve ofthe LogFlag is OFF. This means any ‘message belonging tothe custom flag wall not be logged by the FSLogger, unless its turned ON externally by the user. If a particular custom flag needs to be ON by default, the function LegRegisterCustomPlagEx can be used. This function takes an additional parameter, which sets the faut value ofthe custom flag lf ths parameter is @ non-zero value, the Custom fag is ON by default. All messages using ths fag wilthen be logged by the Logger (provided the flag is not tured OFF externally). To register @ Custom flag with defaut value as ON. Dim CookieON as long Cookie ON = LogRegisterCustomFlagEx (‘PerfData'1) “To register the flag with default value as OFF (which s equivalent to LogRegisterCustomFiag) Dim CookieOFF as long CookieOFF = LogReaisterCustomFlagEx ("PerfData’ 0) Note: Even though a custom flag's state can be set programmatically as shown above, the user can override the state by editing this fag extemally Logging Under a Different Identity Name |Log messages from the components are prefixed with an Identity name, which can then be used to distinguish the messages from individual ‘components “The Logger automatically sets default identity name for each component based on the name ofthe module inside which the component resides. the module is an EXE/OCXIdi, the default kdeniy name is the same as the module file name without the Mle extension (exe. ocx ofl) For example, for a component that is packaged in MyComponentall the defautt identity name wil be MyComponent “To log under an Identity name other than the default identity name, use the function LegSetldentityName. The function takes a string that specifies the identiy name to be usedt LogSetidentiyName Myldentity 201s AVEVA Gp mi ii Asch eared AVEVA eons beat Figure + Lag erty = Kevin Selective Logging “Logging using the above-mentioned functions can be tuned ON/OFF by editing the appropriate LogFlags. For more information an how to configure the required level of Logging by eciting the LogFiags, refer to LogFlag Editor Usage Guide 4 gs re tes OF rafcoune Lanbesenet ranean Post Keane Lea 4 Figure 5: Selecive Log Flags ‘Source Code and Instruction ‘To download sample Visual Basic source code, cick here. ‘Te download sample Visual C++® source code cick here. ATTACHMENTS ‘TNO WWiogger_sample.zip 015 SEA sid 8s ee AVEVA

You might also like