Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Platform/Logger.cpp26
-rw-r--r--src/Platform/Logger.h2
-rw-r--r--src/Platform/Platform.cpp2
3 files changed, 17 insertions, 13 deletions
diff --git a/src/Platform/Logger.cpp b/src/Platform/Logger.cpp
index 937132e2..05dafaca 100644
--- a/src/Platform/Logger.cpp
+++ b/src/Platform/Logger.cpp
@@ -29,25 +29,29 @@ Logger::Logger(LogLevel logLvl) noexcept : logFile(), lastFlushTime(0), lastFlus
{
}
-void Logger::Start(time_t time, const StringRef& filename) noexcept
+GCodeResult Logger::Start(time_t time, const StringRef& filename, const StringRef& reply) noexcept
{
if (!inLogger && logLevel > LogLevel::off)
{
Lock loggerLock(inLogger);
FileStore * const f = reprap.GetPlatform().OpenSysFile(filename.c_str(), OpenMode::append);
- if (f != nullptr)
+ if (f == nullptr)
{
- logFile.Set(f);
- lastFlushFileSize = logFile.Length();
- logFile.Seek(lastFlushFileSize);
- logFileName.copy(filename.c_str());
- String<StringLength50> startMessage;
- startMessage.printf("Event logging started at level %s\n", logLevel.ToString());
- InternalLogMessage(time, startMessage.c_str(), MessageLogLevel::info);
- LogFirmwareInfo(time);
- reprap.StateUpdated();
+ reply.printf("Unable to create or open file %s", filename.c_str());
+ return GCodeResult::error;
}
+
+ logFile.Set(f);
+ lastFlushFileSize = logFile.Length();
+ logFile.Seek(lastFlushFileSize);
+ logFileName.copy(filename.c_str());
+ String<StringLength50> startMessage;
+ startMessage.printf("Event logging started at level %s\n", logLevel.ToString());
+ InternalLogMessage(time, startMessage.c_str(), MessageLogLevel::info);
+ LogFirmwareInfo(time);
+ reprap.StateUpdated();
}
+ return GCodeResult::ok;
}
// TODO: Move this to a more sensible location ?
diff --git a/src/Platform/Logger.h b/src/Platform/Logger.h
index b612bb7d..ccea4d5d 100644
--- a/src/Platform/Logger.h
+++ b/src/Platform/Logger.h
@@ -22,7 +22,7 @@ class Logger
public:
Logger(LogLevel logLvl) noexcept;
- void Start(time_t time, const StringRef& file) noexcept;
+ GCodeResult Start(time_t time, const StringRef& file, const StringRef& reply) noexcept;
void Stop(time_t time) noexcept;
void LogMessage(time_t time, const char *message, MessageType type) noexcept;
void LogMessage(time_t time, OutputBuffer *buf, MessageType type) noexcept;
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index b596c1d6..0de09f38 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -3600,7 +3600,7 @@ GCodeResult Platform::ConfigureLogging(GCodeBuffer& gb, const StringRef& reply)
{
filename.copy(DEFAULT_LOG_FILE);
}
- logger->Start(realTime, filename);
+ return logger->Start(realTime, filename, reply);
}
}
else