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
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-03-12 00:53:47 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-03-12 00:53:47 +0300
commita41de3b73d0bfdf13c332d2425870b7bf6de84da (patch)
treee5f305bda5a636ef6a420f428010c29fa548d261
parent50d3f4727f7e09a649d8b757f2ebe69a6190cecf (diff)
Aded error message if M929 fails to create the log file
-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