diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-01-16 03:30:37 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-01-16 03:30:37 +0000 |
commit | e6422e9ea4dc0d47cbc9ad3ee0f88bfb99ff9130 (patch) | |
tree | 03812cf85bbba08e53c1d551295755d8a30f0d56 /examples/Log_Msg | |
parent | 09c33a49f7fd650e9137cbeb072f4a4cbd59fd72 (diff) | |
download | ATCD-e6422e9ea4dc0d47cbc9ad3ee0f88bfb99ff9130.tar.gz |
*** empty log message ***
Diffstat (limited to 'examples/Log_Msg')
-rw-r--r-- | examples/Log_Msg/Callback.dsp | 61 | ||||
-rw-r--r-- | examples/Log_Msg/Log_Msg.dsp | 2 | ||||
-rw-r--r-- | examples/Log_Msg/Makefile | 2 | ||||
-rw-r--r-- | examples/Log_Msg/Ostream.dsp | 2 | ||||
-rw-r--r-- | examples/Log_Msg/README | 3 | ||||
-rw-r--r-- | examples/Log_Msg/test_callback.cpp | 113 |
6 files changed, 180 insertions, 3 deletions
diff --git a/examples/Log_Msg/Callback.dsp b/examples/Log_Msg/Callback.dsp new file mode 100644 index 00000000000..6e509057f85 --- /dev/null +++ b/examples/Log_Msg/Callback.dsp @@ -0,0 +1,61 @@ +# Microsoft Developer Studio Project File - Name="Callback" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Callback - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Callback.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Callback.mak" CFG="Callback - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Callback - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ace"
+# Begin Target
+
+# Name "Callback - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=test_callback.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/examples/Log_Msg/Log_Msg.dsp b/examples/Log_Msg/Log_Msg.dsp index c126200f434..7a20a91e488 100644 --- a/examples/Log_Msg/Log_Msg.dsp +++ b/examples/Log_Msg/Log_Msg.dsp @@ -37,7 +37,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\\" /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
diff --git a/examples/Log_Msg/Makefile b/examples/Log_Msg/Makefile index 61de5512d5f..20feb237cc2 100644 --- a/examples/Log_Msg/Makefile +++ b/examples/Log_Msg/Makefile @@ -8,7 +8,7 @@ # Local macros #---------------------------------------------------------------------------- -BIN = test_log_msg test_ostream +BIN = test_log_msg test_ostream test_callback LSRC = $(addsuffix .cpp,$(BIN)) diff --git a/examples/Log_Msg/Ostream.dsp b/examples/Log_Msg/Ostream.dsp index fdf6d41d487..c3a1cc938f0 100644 --- a/examples/Log_Msg/Ostream.dsp +++ b/examples/Log_Msg/Ostream.dsp @@ -45,7 +45,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ace"
+# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ace"
# Begin Target
# Name "Ostream - Win32 Debug"
diff --git a/examples/Log_Msg/README b/examples/Log_Msg/README index 2816b61a6fd..08e43550c04 100644 --- a/examples/Log_Msg/README +++ b/examples/Log_Msg/README @@ -1,6 +1,9 @@ This directory contains program(s) that demonstrate how to use ACE's Log_Msg class to record various information. + * test_callback.cpp: This program tests the Log_Msg + abstraction wrt writing to user defined callback objects. + * test_ostream.cpp: This program illustrates how the ACE_Log_Msg abstraction can be used to write to stderr and to a file. For even more sophisticated diff --git a/examples/Log_Msg/test_callback.cpp b/examples/Log_Msg/test_callback.cpp new file mode 100644 index 00000000000..61ad6d2f6ca --- /dev/null +++ b/examples/Log_Msg/test_callback.cpp @@ -0,0 +1,113 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// examples/Log_Msg +// +// = FILENAME +// test_callback.cpp +// +// = DESCRIPTION +// This program tests the Log_Msg abstraction wrt writing to user +// defined callback objects. +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + +#include "ace/OS.h" +#include "ace/streams.h" + +ACE_RCSID(Log_Msg, test_callback, "$Id$") + +class Logger : public ACE_Log_Msg_Callback +{ +public: + void log (ACE_Log_Record &log_record); + // Logging callback + + int verbose_logging_; + // Flag for verbose logging +}; + +void +Logger::log (ACE_Log_Record &log_record) +{ + if (!this->verbose_logging_) + { + cerr << "Logger::log -> " << log_record.msg_data () << endl; + } + else + { + char verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; + int result = log_record.format_msg (ACE_LOG_MSG->local_host (), + ACE_LOG_MSG->flags (), + verbose_msg); + + if (result == 0) + { + cerr << "Logger::log -> " << verbose_msg << endl; + } + } +} + +int +main (int argc, char *argv[]) +{ + // This message should show up in stderr. + ACE_DEBUG ((LM_DEBUG, + "first message\n")); + + ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); + + // This message should not show up anywhere. + ACE_DEBUG ((LM_DEBUG, + "second message\n")); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::MSG_CALLBACK); + + // This message should not show up anywhere since no callback object + // has been specified. + ACE_DEBUG ((LM_DEBUG, + "third message\n")); + + // Create a callback object. + Logger logger; + logger.verbose_logging_ = 1; + + // Set the callback object. + ACE_LOG_MSG->msg_callback (&logger); + + // This message should show up in the logger. + ACE_DEBUG ((LM_DEBUG, + "forth message\n")); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE); + + // This message should show up in the logger (somewhat loudly). + ACE_DEBUG ((LM_DEBUG, + "fifth message\n")); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE); + + // This message should show up in the logger (really loudly). + ACE_DEBUG ((LM_DEBUG, + "sixth message\n")); + + logger.verbose_logging_ = 0; + + // This message should show up in the logger (not loudly). + ACE_DEBUG ((LM_DEBUG, + "seventh message\n")); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); + + // This message should show up in stderr and the logger. The one + // from the logger will not be loud, but the one from stderr should + // be loud. + ACE_DEBUG ((LM_DEBUG, + "eight message\n")); + return 0; +} |