27 const String& welcomeMessage,
28 const int64 maxInitialFileSizeBytes)
31 if (maxInitialFileSizeBytes >= 0)
39 <<
"**********************************************************" << newLine
40 << welcomeMessage << newLine
54 out << message << newLine;
59 if (maxFileSizeBytes <= 0)
65 const int64 fileSize = file.
getSize();
67 if (fileSize > maxFileSizeBytes)
86 if (c ==
'\n' || c ==
'\r')
105 return File (
"~/Library/Logs");
112 const String& logFileName,
113 const String& welcomeMessage,
114 const int64 maxInitialFileSizeBytes)
117 .getChildFile (logFileName),
118 welcomeMessage, maxInitialFileSizeBytes);
122 const String& logFileNameRoot,
123 const String& logFileNameSuffix,
124 const String& welcomeMessage)
128 .withFileExtension (logFileNameSuffix)
129 .getNonexistentSibling(),
A simple implementation of a Logger that writes to a file.
FileLogger(const File &fileToWriteTo, const String &welcomeMessage, const int64 maxInitialFileSizeBytes=128 *1024)
Creates a FileLogger for a given file.
static FileLogger * createDefaultAppLogger(const String &logFileSubDirectoryName, const String &logFileName, const String &welcomeMessage, const int64 maxInitialFileSizeBytes=128 *1024)
Helper function to create a log file in the correct place for this platform.
static void trimFileSize(const File &file, int64 maxFileSize)
This is a utility function which removes lines from the start of a text file to make sure that its to...
static File getSystemLogFileFolder()
Returns an OS-specific folder where log-files should be stored.
~FileLogger() override
Destructor.
static FileLogger * createDateStampedLogger(const String &logFileSubDirectoryName, const String &logFileNameRoot, const String &logFileNameSuffix, const String &welcomeMessage)
Helper function to create a log file in the correct place for this platform.
void logMessage(const String &) override
This is overloaded by subclasses to implement custom logging behaviour.
An output stream that writes into a local file.
bool openedOk() const noexcept
Returns true if the stream opened without problems.
Represents a local file or directory.
int64 getSize() const
Returns the size of the file in bytes.
static File JUCE_CALLTYPE getSpecialLocation(const SpecialLocationType type)
Finds the location of a special type of file or directory, such as a home folder or documents folder.
@ userApplicationDataDirectory
The folder in which applications store their persistent user-specific settings.
Result create() const
Creates an empty file if it doesn't already exist.
bool deleteFile() const
Deletes a file.
bool exists() const
Checks whether the file actually exists.
Automatically locks and unlocks a mutex object.
virtual int64 writeFromInputStream(InputStream &source, int64 maxNumBytesToWrite)
Reads data from an input stream and writes it to this stream.
Manages a temporary file, which will be deleted when this object is deleted.
bool overwriteTargetFileWithTemporary() const
Tries to move the temporary file to overwrite the target file that was specified in the constructor.
const File & getFile() const noexcept
Returns the temporary file.
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.
String toString(bool includeDate, bool includeTime, bool includeSeconds=true, bool use24HourClock=false) const
Returns a string version of this date and time, using this machine's local timezone.