node.\+js file streams that roll over when they reach a maximum size, or a date/time. \begin{DoxyVerb}    npm install streamroller
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_streamroller_README_autotoc_md29069}{}\doxysection{usage}\label{md_sfcode_node_modules_streamroller_README_autotoc_md29069}
\begin{DoxyVerb}    var rollers = require('streamroller');
    var stream = new rollers.RollingFileStream('myfile', 1024, 3);
    stream.write("stuff");
    stream.end();
\end{DoxyVerb}
 The streams behave the same as standard node.\+js streams, except that when certain conditions are met they will rename the current file to a backup and start writing to a new file.\hypertarget{md_sfcode_node_modules_streamroller_README_autotoc_md29070}{}\doxysubsection{new Rolling\+File\+Stream(filename \mbox{[}, max\+Size, num\+Backups, options\mbox{]})}\label{md_sfcode_node_modules_streamroller_README_autotoc_md29070}

\begin{DoxyItemize}
\item {\ttfamily filename} (String)
\item {\ttfamily max\+Size} -\/ the size in bytes to trigger a rollover, if not provided this defaults to MAX\+\_\+\+SAFE\+\_\+\+INTEGER and the stream will not roll.
\item {\ttfamily num\+Backups} -\/ the number of old files to keep
\item {\ttfamily options} -\/ Object
\begin{DoxyItemize}
\item {\ttfamily encoding} -\/ defaults to \textquotesingle{}utf8\textquotesingle{}
\item {\ttfamily mode} -\/ defaults to 0644
\item {\ttfamily flags} -\/ defaults to \textquotesingle{}a\textquotesingle{} (see \href{https://nodejs.org/dist/latest-v8.x/docs/api/fs.html\#fs_fs_open_path_flags_mode_callback}{\texttt{ fs.\+open}} for more details)
\item {\ttfamily compress} -\/ (boolean) defaults to {\ttfamily false} -\/ compress the backup files using gzip (files will have {\ttfamily .gz} extension).
\item {\ttfamily keep\+File\+Ext} -\/ (boolean) defaults to {\ttfamily false} -\/ keep the file original extension. e.\+g.\+: {\ttfamily abc.\+log -\/$>$ abc.\+1.\+log}.
\end{DoxyItemize}
\end{DoxyItemize}

This returns a {\ttfamily Writable\+Stream}. When the current file being written to (given by {\ttfamily filename}) gets up to or larger than {\ttfamily max\+Size}, then the current file will be renamed to {\ttfamily filename.\+1} and a new file will start being written to. Up to {\ttfamily num\+Backups} of old files are maintained, so if {\ttfamily num\+Backups} is 3 then there will be 4 files\+: 
\begin{DoxyPre}
     filename
     filename.1
     filename.2
     filename.3
\end{DoxyPre}
 When filename size $>$= max\+Size then\+: 
\begin{DoxyPre}
     filename -\/> filename.1
     filename.1 -\/> filename.2
     filename.2 -\/> filename.3
     filename.3 gets overwritten
     filename is a new file
\end{DoxyPre}


\#\hypertarget{md_sfcode_node_modules_streamroller_README_autotoc_md29071}{}\doxysection{new Date\+Rolling\+File\+Stream(filename, pattern, options)}\label{md_sfcode_node_modules_streamroller_README_autotoc_md29071}

\begin{DoxyItemize}
\item {\ttfamily filename} (String)
\item {\ttfamily pattern} (String) -\/ the date pattern to trigger rolling (see below)
\item {\ttfamily options} -\/ Object
\begin{DoxyItemize}
\item {\ttfamily encoding} -\/ defaults to \textquotesingle{}utf8\textquotesingle{}
\item {\ttfamily mode} defaults to 0644
\item {\ttfamily flags} defaults to \textquotesingle{}a\textquotesingle{} (see \href{https://nodejs.org/dist/latest-v8.x/docs/api/fs.html\#fs_fs_open_path_flags_mode_callback}{\texttt{ fs.\+open}} for more details)
\item {\ttfamily compress} -\/ (boolean) compress the backup files, defaults to false
\item {\ttfamily keep\+File\+Ext} -\/ (boolean) defaults to {\ttfamily false} -\/ keep the file original extension. e.\+g.\+: {\ttfamily abc.\+log -\/$>$ abc.\+2013-\/08-\/30.\+log}.
\item {\ttfamily always\+Include\+Pattern} -\/ (boolean) extend the initial file with the pattern, defaults to false
\end{DoxyItemize}
\end{DoxyItemize}

{\ttfamily days\+To\+Keep} -\/ (integer) if this is greater than 0, then files older than {\ttfamily days\+To\+Keep} days will be deleted during file rolling.

This returns a {\ttfamily Writable\+Stream}. When the current time, formatted as {\ttfamily pattern}, changes then the current file will be renamed to {\ttfamily filename.\+formatted\+Date} where {\ttfamily formatted\+Date} is the result of processing the date through the pattern, and a new file will begin to be written. Streamroller uses \href{http://github.com/nomiddlename/date-format}{\texttt{ date-\/format}} to format dates, and the {\ttfamily pattern} should use the date-\/format format. e.\+g. with a {\ttfamily pattern} of {\ttfamily \char`\"{}.\+yyyy-\/\+MM-\/dd\char`\"{}}, and assuming today is August 29, 2013 then writing to the stream today will just write to {\ttfamily filename}. At midnight (or more precisely, at the next file write after midnight), {\ttfamily filename} will be renamed to {\ttfamily filename.\+2013-\/08-\/29} and a new {\ttfamily filename} will be created. If {\ttfamily options.\+always\+Include\+Pattern} is true, then the initial file will be {\ttfamily filename.\+2013-\/08-\/29} and no renaming will occur at midnight, but a new file will be written to with the name {\ttfamily filename.\+2013-\/08-\/30}. 