# PetscVFPrintf
All PETSc standard out and error messages are sent through this function; so, in theory, this can can be replaced with something that does not simply write to a file. 
## Synopsis
```
PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char *format, va_list Argp)
```
To use, write your own function for example,
```none
PetscErrorCode mypetscvfprintf(FILE *fd,const char format[],va_list Argp)
```
```none
{$  PetscErrorCode ierr;
```
```none
```
```none
PetscFunctionBegin;
```
```none
if (fd != stdout && fd != stderr) {  handle regular files
```
```none
CHKERR(PetscVFPrintfDefault(fd,format,Argp));
```
```none
} else {
```
```none
char   buff[BIG];
```
```none
size_t length;
```
```none
PetscCall(PetscVSNPrintf(buff,BIG,format,&length,Argp));
```
```none
now send buff to whatever stream or whatever you want
```
```none
}
```
```none
PetscFunctionReturn(0);
```
```none
}then before the call to PetscInitialize() do the assignment
```
```none
PetscVFPrintf = mypetscvfprintf;
```


## Note
For error messages this may be called by any process, for regular standard out it is
called only by process 0 of a given communicator


## Developer Note
this could be called by an error handler, if that happens then a recursion of the error handler may occur
and a crash




## See Also
 `PetscVSNPrintf()`, `PetscErrorPrintf()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/fileio/mprint.c.html#PetscVFPrintf">src/sys/fileio/mprint.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/fileio/mprint.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
