diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-06-22 17:54:18 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2000-06-22 17:54:18 +0000 |
commit | b03094e170beca85d45bdd17974c5b9e8d3e3857 (patch) | |
tree | cdede980ac5605ba1dd1baa798fa05a8d907abd6 /netsvcs | |
parent | cfd33e0db82112b8eeddfbd7f6941276004c800a (diff) | |
download | ATCD-b03094e170beca85d45bdd17974c5b9e8d3e3857.tar.gz |
ChangeLogTag:Thu Jun 22 12:46:43 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
Diffstat (limited to 'netsvcs')
-rw-r--r-- | netsvcs/lib/Logging_Strategy.cpp | 228 | ||||
-rw-r--r-- | netsvcs/lib/Logging_Strategy.h | 91 | ||||
-rw-r--r-- | netsvcs/lib/Makefile | 108 | ||||
-rw-r--r-- | netsvcs/servers/svc.conf | 2 |
4 files changed, 9 insertions, 420 deletions
diff --git a/netsvcs/lib/Logging_Strategy.cpp b/netsvcs/lib/Logging_Strategy.cpp deleted file mode 100644 index d34d9c7a1a8..00000000000 --- a/netsvcs/lib/Logging_Strategy.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// $Id$ - -#define ACE_BUILD_SVC_DLL - -#include "ace/Get_Opt.h" -#include "ace/streams.h" -#include "ace/Log_Msg.h" -#include "ace/Reactor.h" -#include "Logging_Strategy.h" - -ACE_RCSID(lib, Logging_Strategy, "$Id$") - -// Parse the string containing all the flags and set the flags -// accordingly. - -void -ACE_Logging_Strategy::tokenize (char *flag_string) -{ - for (char *flag = ACE_OS::strtok (flag_string, "|"); - flag != 0; - flag = ACE_OS::strtok (0, "|")) - { - if (ACE_OS::strcmp (flag, "STDERR") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::STDERR); - else if (ACE_OS::strcmp (flag, "LOGGER") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER); - else if (ACE_OS::strcmp (flag, "OSTREAM") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); - else if (ACE_OS::strcmp (flag, "VERBOSE") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE); - else if (ACE_OS::strcmp (flag, "VERBOSE_LITE") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE_LITE); - else if (ACE_OS::strcmp (flag, "SILENT") == 0) - ACE_SET_BITS (this->flags_, ACE_Log_Msg::SILENT); - } -} - -int -ACE_Logging_Strategy::parse_args (int argc, char *argv[]) -{ - ACE_TRACE ("ACE_Logging_Strategy::parse_args"); - char *temp; - - this->flags_ = 0; - this->wipeout_logfile_ = 0; - this->interval_ = 0; - this->max_size_ = ACE_DEFAULT_MAX_LOGFILE_SIZE; - - ACE_Get_Opt get_opt (argc, argv, "f:i:m:s:w", 0); - - for (int c; (c = get_opt ()) != -1; ) - { - switch (c) - { - case 'f': - temp = get_opt.optarg; - // Now tokenize the string to get all the flags - this->tokenize (temp); - break; - case 'i': - // Interval (in secs) at which logfile size is sampled. - this->interval_ = ACE_OS::strtoul (get_opt.optarg, 0, 10); - break; - case 'm': - // Maximum logfile size (in KB). Must be a non-zero value. - this->max_size_ = ACE_OS::strtoul (get_opt.optarg, 0, 10); - if (this->max_size_ == 0) - this->max_size_ = ACE_DEFAULT_MAX_LOGFILE_SIZE; - this->max_size_ <<= 10; // convert to KB - break; - case 's': - // Ensure that the OSTREAM flag is set - ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM); - delete [] this->filename_; - this->filename_ = ACE::strnew (get_opt.optarg); - break; - case 'w': - // Cause the logfile to be wiped out, both on startup and on - // reconfigure. - this->wipeout_logfile_ = 1; - break; - default: - break; - } - } - return 0; -} - -ACE_Logging_Strategy::ACE_Logging_Strategy (void) -{ -#if defined (ACE_DEFAULT_LOGFILE) - this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE); -#else /* ACE_DEFAULT_LOGFILE */ - ACE_NEW (this->filename_, char[MAXPATHLEN + 1]); - - // Get the temporary directory - if (ACE::get_temp_dir (this->filename_, - MAXPATHLEN - 7) == -1) // 7 for "logfile" - { - ACE_ERROR ((LM_ERROR, - "Temporary path too long, defaulting to current directory\n")); - this->filename_[0] = 0; - } - - // Add the filename to the end - ACE_OS::strcat (this->filename_, - "logfile"); -#endif /* ACE_DEFAULT_LOGFILE */ -} - -int -ACE_Logging_Strategy::fini (void) -{ - delete [] this->filename_; - return 0; -} - -int -ACE_Logging_Strategy::init (int argc, char *argv[]) -{ - ACE_TRACE ("ACE_Logging_Strategy::init"); - - // Use the options hook to parse the command line arguments. - this->parse_args (argc, argv); - - // Check if any flags were specified. If none were specified, let - // the default behavior take effect. - if (this->flags_ != 0) - { - // Clear all flags - ACE_Log_Msg::instance ()->clr_flags (ACE_Log_Msg::STDERR - | ACE_Log_Msg::LOGGER - | ACE_Log_Msg::OSTREAM - | ACE_Log_Msg::VERBOSE - | ACE_Log_Msg::VERBOSE_LITE - | ACE_Log_Msg::SILENT); - // Check if OSTREAM bit is set - if (ACE_BIT_ENABLED (this->flags_, - ACE_Log_Msg::OSTREAM)) - { - ofstream *output_file = 0; - // Create a new ofstream to direct output to the file. - if (wipeout_logfile_) - ACE_NEW_RETURN (output_file, - ofstream (this->filename_), - -1); - else - ACE_NEW_RETURN (output_file, - ofstream (this->filename_, - ios::app | ios::out), - -1); - - // Set the <output_file> that'll be used by the rest of the - // code. - ACE_Log_Msg::instance ()->msg_ostream (output_file); - - // Setup a timeout handler to perform the maximum file size - // check (if required). - if (this->interval_ > 0) - { - if (this->reactor () == 0) - this->reactor (ACE_Reactor::instance ()); // Use singleton - this->reactor ()->schedule_timer (this, 0, - ACE_Time_Value (this->interval_), - ACE_Time_Value (this->interval_)); - } - } - // Now set the flags for Log_Msg - ACE_Log_Msg::instance ()->set_flags (this->flags_); - } - - return ACE_LOG_MSG->open ("Logging_Strategy", - ACE_LOG_MSG->flags (), - ACE_TEXT_CHAR_TO_TCHAR (ACE_DEFAULT_LOGGER_KEY)); -} - -int -ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &, - const void *) -{ - if ((size_t) ACE_LOG_MSG->msg_ostream ()->tellp () > this->max_size_) - { - // Lock out any other logging. - if (ACE_LOG_MSG->acquire ()) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Cannot acquire lock!\n")), - -1); - - // Close the current ostream. - ofstream *output_file = - (ofstream *) ACE_LOG_MSG->msg_ostream (); - output_file->close (); - - // Save current logfile to logfile.old - if (ACE_OS::strlen (this->filename_) + 4 <= MAXPATHLEN) // 4 for ".old" - { - char backup[MAXPATHLEN+1]; - - ACE_OS::strcpy (backup, this->filename_); - ACE_OS::strcat (backup, ".old"); - - // Remove any existing .old file; ignore error as file may - // not exist. - ACE_OS::unlink (backup); - - // Rename the current log file to the name of the backup log - // file. - ACE_OS::rename (this->filename_, - backup); - } - else - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Backup file name too long; backup logfile not saved.\n"))); - - // Open a new log file by the same name - output_file->open (this->filename_, ios::out); - - // Release the lock previously acquired. - ACE_LOG_MSG->release (); - } - - return 0; -} - -// The following is a "Factory" used by the ACE_Service_Config and -// svc.conf file to dynamically initialize the state of the Logging_Strategy. - -ACE_SVC_FACTORY_DEFINE (ACE_Logging_Strategy) diff --git a/netsvcs/lib/Logging_Strategy.h b/netsvcs/lib/Logging_Strategy.h deleted file mode 100644 index 0e299d78690..00000000000 --- a/netsvcs/lib/Logging_Strategy.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Logging_Strategy.h -// -// = AUTHOR -// Prashant Jain <pjain@cs.wustl.edu> -// -// ============================================================================ - -#ifndef ACE_LOGGING_STRATEGY_H -#define ACE_LOGGING_STRATEGY_H - -#include "ace/Service_Object.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if !defined (ACE_DEFAULT_MAX_LOGFILE_SIZE) -#define ACE_DEFAULT_MAX_LOGFILE_SIZE 16384 /* KB */ -#endif /* ACE_DEFAULT_MAX_LOGFILE_SIZE */ - - -class ACE_Logging_Strategy : public ACE_Service_Object -{ - // = TITLE - // This class provides the hooks to control the output produced - // by any of the network services. - // - // = DESCRIPTION - // Depending upon when this service is invoked and with what - // flags, the output of other network services can be - // controlled. The output can be streamed to stderr, to a file, - // to a logging daemon, or it can be set to be "silent". - // - // If logging records are output to a file, the file can be set - // to a maximum size and repeatedly split into new files. The - // log file size can be limited at any logging point (i.e., - // application, client logging daemon, or server logging daemon) - // by specifying the -i <sample_interval_in_secs> and -m - // <max_size_in_KB> options for the Logging_Strategy class in a - // svc.conf file. -public: - ACE_Logging_Strategy (void); - // Constructor. - - virtual int init (int argc, char *argv[]); - // Dynamic linking initialization hook. - - virtual int fini (void); - // Dynamic linking termination hook. - - virtual int handle_timeout (const ACE_Time_Value& tv, const void* arg); - // Timeout handler which tests logfile size. If the current logfile - // size exceeds <max_size_>, the current logfile is closed, saved to - // logfile.old, and a new logfile is reopened. - - int parse_args (int argc, char *argv[]); - // Parse svc.conf arguments. - -private: - void tokenize (char *flag_string); - // Tokenize to set all the flags - - u_long flags_; - // Flags we keep track of. - - char *filename_; - // File name we're logging to. - - int wipeout_logfile_; - // If non-0 then wipeout the logfile, otherwise append to it. - - u_long interval_; - // If non-zero, sampling interval (in secs) at which maximum logfile - // size is checked, otherwise logfile size can grow indefinitely. - - u_long max_size_; - // Maximum logfile size (in KB). -}; - -ACE_SVC_FACTORY_DECLARE (ACE_Logging_Strategy) - -#endif /* ACE_LOGGING_STRATEGY_H */ diff --git a/netsvcs/lib/Makefile b/netsvcs/lib/Makefile index 0733a8be883..74f2310121a 100644 --- a/netsvcs/lib/Makefile +++ b/netsvcs/lib/Makefile @@ -8,15 +8,14 @@ LIB = libnetsvcs.a SHLIB = libnetsvcs.$(SOEXT) FILES = TS_Server_Handler \ - TS_Clerk_Handler \ - Client_Logging_Handler \ - Name_Handler \ - Server_Logging_Handler_T \ - Log_Message_Receiver \ - Server_Logging_Handler \ - Token_Handler \ - Logging_Strategy \ - Base_Optimizer + TS_Clerk_Handler \ + Client_Logging_Handler \ + Name_Handler \ + Server_Logging_Handler_T \ + Log_Message_Receiver \ + Server_Logging_Handler \ + Token_Handler \ + Base_Optimizer DEFS = $(addsuffix .h,$(FILES)) LSRC = $(addsuffix .cpp,$(FILES)) @@ -1279,97 +1278,6 @@ endif # SUPPRESS_DASH_G $(ACE_ROOT)/ace/Token_Request_Reply.h \ $(ACE_ROOT)/ace/Token_Request_Reply.i -.obj/Logging_Strategy.o .obj/Logging_Strategy.so .shobj/Logging_Strategy.o .shobj/Logging_Strategy.so: Logging_Strategy.cpp \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/pre.h \ - $(ACE_ROOT)/ace/ACE.h \ - $(ACE_ROOT)/ace/OS.h \ - $(ACE_ROOT)/ace/post.h \ - $(ACE_ROOT)/ace/ace_wchar.h \ - $(ACE_ROOT)/ace/ACE_export.h \ - $(ACE_ROOT)/ace/svc_export.h \ - $(ACE_ROOT)/ace/OS_Dirent.h \ - $(ACE_ROOT)/ace/OS_Export.h \ - $(ACE_ROOT)/ace/OS_Dirent.inl \ - $(ACE_ROOT)/ace/OS_String.h \ - $(ACE_ROOT)/ace/OS_String.inl \ - $(ACE_ROOT)/ace/OS_Memory.h \ - $(ACE_ROOT)/ace/OS_Memory.inl \ - $(ACE_ROOT)/ace/OS_TLI.h \ - $(ACE_ROOT)/ace/OS_TLI.inl \ - $(ACE_ROOT)/ace/Min_Max.h \ - $(ACE_ROOT)/ace/streams.h \ - $(ACE_ROOT)/ace/Basic_Types.h \ - $(ACE_ROOT)/ace/Basic_Types.i \ - $(ACE_ROOT)/ace/Trace.h \ - $(ACE_ROOT)/ace/OS.i \ - $(ACE_ROOT)/ace/Log_Msg.h \ - $(ACE_ROOT)/ace/Log_Record.h \ - $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - $(ACE_ROOT)/ace/ACE.i \ - $(ACE_ROOT)/ace/Get_Opt.i \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/Handle_Set.i \ - $(ACE_ROOT)/ace/Timer_Queue.h \ - $(ACE_ROOT)/ace/Synch.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ - $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ - $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ - $(ACE_ROOT)/ace/Synch.i \ - $(ACE_ROOT)/ace/Synch_T.h \ - $(ACE_ROOT)/ace/Event_Handler.h \ - $(ACE_ROOT)/ace/Event_Handler.i \ - $(ACE_ROOT)/ace/Synch_T.i \ - $(ACE_ROOT)/ace/Thread.h \ - $(ACE_ROOT)/ace/Thread.i \ - $(ACE_ROOT)/ace/Atomic_Op.i \ - $(ACE_ROOT)/ace/Synch_T.cpp \ - $(ACE_ROOT)/ace/Timer_Queue_T.h \ - $(ACE_ROOT)/ace/Free_List.h \ - $(ACE_ROOT)/ace/Free_List.i \ - $(ACE_ROOT)/ace/Free_List.cpp \ - $(ACE_ROOT)/ace/Timer_Queue_T.i \ - $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ - $(ACE_ROOT)/ace/Signal.h \ - $(ACE_ROOT)/ace/Containers.h \ - $(ACE_ROOT)/ace/Malloc_Base.h \ - $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers_T.h \ - $(ACE_ROOT)/ace/Containers_T.i \ - $(ACE_ROOT)/ace/Containers_T.cpp \ - $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Based_Pointer_T.h \ - $(ACE_ROOT)/ace/Based_Pointer_T.i \ - $(ACE_ROOT)/ace/Based_Pointer_T.cpp \ - $(ACE_ROOT)/ace/Based_Pointer_Repository.h \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Object_Manager.h \ - $(ACE_ROOT)/ace/Object_Manager.i \ - $(ACE_ROOT)/ace/Managed_Object.h \ - $(ACE_ROOT)/ace/Managed_Object.i \ - $(ACE_ROOT)/ace/Managed_Object.cpp \ - $(ACE_ROOT)/ace/Malloc.i \ - $(ACE_ROOT)/ace/Malloc_T.h \ - $(ACE_ROOT)/ace/Malloc_T.i \ - $(ACE_ROOT)/ace/Malloc_T.cpp \ - $(ACE_ROOT)/ace/Memory_Pool.h \ - $(ACE_ROOT)/ace/Mem_Map.h \ - $(ACE_ROOT)/ace/Mem_Map.i \ - $(ACE_ROOT)/ace/Memory_Pool.i \ - $(ACE_ROOT)/ace/Signal.i \ - $(ACE_ROOT)/ace/Reactor.i \ - $(ACE_ROOT)/ace/Reactor_Impl.h \ - Logging_Strategy.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i - .obj/Base_Optimizer.o .obj/Base_Optimizer.so .shobj/Base_Optimizer.o .shobj/Base_Optimizer.so: Base_Optimizer.cpp Base_Optimizer.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/pre.h \ diff --git a/netsvcs/servers/svc.conf b/netsvcs/servers/svc.conf index 66dafa4e0e3..0d807b12ae8 100644 --- a/netsvcs/servers/svc.conf +++ b/netsvcs/servers/svc.conf @@ -8,7 +8,7 @@ # hardcoded "-p 20xxx" with "-p $PORTxxx" if you set your environment # variables correctly. -dynamic Logger Service_Object * netsvcs:_make_ACE_Logging_Strategy() "-s foobar -f STDERR|OSTREAM" +# dynamic Logger Service_Object * ACE:_make_ACE_Logging_Strategy() "-s foobar -f STDERR|OSTREAM" dynamic Time_Service Service_Object * netsvcs:_make_ACE_TS_Server_Acceptor() "-p 20222" dynamic Name_Server Service_Object * netsvcs:_make_ACE_Name_Acceptor() "-p 20012" dynamic Token_Service Service_Object * netsvcs:_make_ACE_Token_Acceptor() "-p 20202" |