[cig-commits] commit: Added some functionality to enable/disable all typed streams.

Mercurial hg at geodynamics.org
Mon Feb 1 15:32:55 PST 2010


changeset:   733:b38148d32563
branch:      pcu_rejig
parent:      726:f677f87f8188
user:        JericoRevote
date:        Fri Dec 11 15:38:09 2009 +1100
files:       Base/Automation/tests/CallGraphSuite.c Base/IO/src/Journal.c Base/IO/src/Journal.h Base/IO/src/Stream.c Base/IO/src/Stream.h
description:
Added some functionality to enable/disable all typed streams.


diff -r f677f87f8188 -r b38148d32563 Base/Automation/tests/CallGraphSuite.c
--- a/Base/Automation/tests/CallGraphSuite.c	Thu Dec 10 11:58:29 2009 +1100
+++ b/Base/Automation/tests/CallGraphSuite.c	Fri Dec 11 15:38:09 2009 +1100
@@ -161,10 +161,8 @@ void CallGraphSuite_TestTableRealloc( Ca
       /* Use "i" as a unique string (unique pointer value)... don't try to print! */
       Stg_CallGraph_Push( cg3, TestFunc1, (Name)ii );
    }
-   pcu_check_true( 
-      cg3->_tableCount == count && 
-      cg3->_tableSize == (size * 2) );
-   
+   pcu_check_true( cg3->_tableCount == count && cg3->_tableSize == (size * 2) ); 
+
    Stg_Class_Delete(  cg3 );
 }
 
diff -r f677f87f8188 -r b38148d32563 Base/IO/src/Journal.c
--- a/Base/IO/src/Journal.c	Thu Dec 10 11:58:29 2009 +1100
+++ b/Base/IO/src/Journal.c	Fri Dec 11 15:38:09 2009 +1100
@@ -394,6 +394,7 @@ void Journal_RegisterTypedStream( Stream
 	/* check exists and update */
 	Stg_ObjectList_Append( stJournal->_typedStreams, typedStream );
 }
+
 Stream* Journal_GetTypedStream( const Type type )
 {
 	Stream* typedStream = NULL;
@@ -412,6 +413,7 @@ Stream* Journal_GetTypedStream( const Ty
 	
 	return typedStream;
 }
+
 Stream* Journal_GetNamedStream( Stream* typedStream, const Name name )
 {
 	Stream* currentStream ;
@@ -447,9 +449,9 @@ Stream* Journal_Register( const Type typ
 	typedStream = Journal_GetTypedStream( type );
 	namedStream = Journal_GetNamedStream( typedStream, name );	
 	
-
 	return namedStream;
 }
+
 Stream* Journal_Register2( const Type streamType, const Type componentType, const Name componentName ) {
 	Stream* componentStream;
 	Stream* instanceStream;
@@ -486,6 +488,20 @@ void Journal_Enable_TypedStream( const T
 void Journal_Enable_TypedStream( const Type type, Bool enable )
 {
 	Stream* typedStream = Journal_GetTypedStream( type );
+	Stream_Enable( typedStream, enable );
+}
+
+void Journal_Enable_AllTypedStream( Bool enable )
+{
+	Stream* typedStream;
+
+	typedStream = Journal_GetTypedStream( InfoStream_Type );
+	Stream_Enable( typedStream, enable );
+	typedStream = Journal_GetTypedStream( DumpStream_Type );
+	Stream_Enable( typedStream, enable );
+	typedStream = Journal_GetTypedStream( DebugStream_Type );
+	Stream_Enable( typedStream, enable );
+	typedStream = Journal_GetTypedStream( ErrorStream_Type );
 	Stream_Enable( typedStream, enable );
 }
 
diff -r f677f87f8188 -r b38148d32563 Base/IO/src/Journal.h
--- a/Base/IO/src/Journal.h	Thu Dec 10 11:58:29 2009 +1100
+++ b/Base/IO/src/Journal.h	Fri Dec 11 15:38:09 2009 +1100
@@ -148,10 +148,11 @@
 	 ** If the argument is NULL, no operation is performed. */
 	void Journal_DeregisterFile( JournalFile* file ); 
 
-
-
 	/** Enables/Disables the specified typed stream. */
 	void Journal_Enable_TypedStream( const Type type, Bool enable );
+
+	/** Enables/Disables all defined typed streams */
+	void Journal_Enable_AllTypedStream( Bool enable );
 
 	/** Enables/Disables the given named stream.
 	 **
@@ -160,11 +161,8 @@
 	 **/
 	void Journal_Enable_NamedStream( const Type type, const Name name, Bool enable );
 
-
 	/** Prints a summary of the status of each stream in Journal */
 	void Journal_PrintConcise();
-
-
 
 	/** Performs a printf() with the given stream. */
 	int Journal_Printf( void* _stream, const char* const fmt, ... );
diff -r f677f87f8188 -r b38148d32563 Base/IO/src/Stream.c
--- a/Base/IO/src/Stream.c	Thu Dec 10 11:58:29 2009 +1100
+++ b/Base/IO/src/Stream.c	Fri Dec 11 15:38:09 2009 +1100
@@ -314,6 +314,7 @@ SizeT Stream_Write( Stream *stream, void
 	}
 	return result;
 }
+
 Bool Stream_Dump( Stream *stream, void *data )
 {
 	Bool result;
@@ -354,6 +355,39 @@ Bool Stream_RedirectFile( Stream* stream
 	return Stream_SetFile( stream, file );
 }
 
+Bool Stream_RedirectAllToFile( const char* const fileName ) {
+	char* infoStreamFilename;
+	char* debugStreamFilename;
+	char* dumpStreamFilename;
+	char* errorStreamFilename;
+
+	Stg_asprintf( &infoStreamFilename, "%s.info", fileName );
+	Stg_asprintf( &debugStreamFilename, "%s.debug", fileName );
+	Stg_asprintf( &dumpStreamFilename, "%s.dump", fileName );
+	Stg_asprintf( &errorStreamFilename, "%s.error", fileName );
+
+	if( Stream_RedirectFile( Journal_GetTypedStream( Info_Type ), infoStreamFilename ) &&
+		Stream_RedirectFile( Journal_GetTypedStream( Debug_Type ), debugStreamFilename ) &&
+		Stream_RedirectFile( Journal_GetTypedStream( Dump_Type ), dumpStreamFilename ) &&
+		Stream_RedirectFile( Journal_GetTypedStream( Error_Type ), errorStreamFilename ) ) {
+		
+		Stream_ClearCustomFormatters( Journal_GetTypedStream( Info_Type ) );
+		Stream_ClearCustomFormatters( Journal_GetTypedStream( Debug_Type ) );
+		Stream_ClearCustomFormatters( Journal_GetTypedStream( Dump_Type ) );
+		Stream_ClearCustomFormatters( Journal_GetTypedStream( Error_Type ) );
+
+		return True;
+	}
+	else
+		return False;
+}
+
+void Stream_PurgeAllRedirectedFiles( void ) {
+	Stream_CloseAndFreeFile( Journal_GetTypedStream( Info_Type ) );
+	Stream_CloseAndFreeFile( Journal_GetTypedStream( Debug_Type ) );
+	Stream_CloseAndFreeFile( Journal_GetTypedStream( Dump_Type ) );
+	Stream_CloseAndFreeFile( Journal_GetTypedStream( Error_Type ) );
+}
 
 Bool Stream_RedirectFileBranch( Stream* stream, const char* const fileName ) {
 	JournalFile* file;
diff -r f677f87f8188 -r b38148d32563 Base/IO/src/Stream.h
--- a/Base/IO/src/Stream.h	Thu Dec 10 11:58:29 2009 +1100
+++ b/Base/IO/src/Stream.h	Fri Dec 11 15:38:09 2009 +1100
@@ -147,6 +147,13 @@
 	    Defaults CFile for now. TODO for next io commit */
 	Bool Stream_RedirectFile( Stream* stream, const char* const fileName );
 
+	/** Opens a registers a file for all the stream if not already opened and assigns it for output
+	    Defaults CFile for now. TODO for next io commit */
+	Bool Stream_RedirectAllToFile( const char* const fileName );
+
+	/** Purges all redirected stream files */
+	void Stream_PurgeAllRedirectedFiles( void );
+
 	/** Opens a registers a file for this stream if not already opened and assigns it for output for whole branch */
 	Bool Stream_RedirectFileBranch( Stream* stream, const char* const fileName );
 



More information about the CIG-COMMITS mailing list