ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
log_file.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 //=============================================================================
23 //
24 // LogFile, the IOutputHandler implementation that writes to file.
25 //
26 // When created LogFile may open file right away or delay doing this.
27 // In the latter case it will buffer output up to certain size limit.
28 // When told to open the file, it will first flush its buffer. This allows to
29 // log events even before the log path is decided (for example, before or
30 // during reading configuration and/or parsing command line).
31 //
32 //=============================================================================
33 
34 #ifndef AGS_ENGINE_DEBUGGING_LOG_FILE_H
35 #define AGS_ENGINE_DEBUGGING_LOG_FILE_H
36 
37 #include "common/std/memory.h"
38 #include "ags/shared/debugging/output_handler.h"
39 
40 namespace AGS3 {
41 namespace AGS {
42 
43 namespace Shared {
44 class Stream;
45 }
46 
47 namespace Engine {
48 
49 using Shared::DebugMessage;
50 using Shared::Stream;
51 using Shared::String;
52 
54 public:
55  enum OpenMode {
56  kLogFile_Overwrite,
57  kLogFile_OverwriteAtFirstMessage,
58  kLogFile_Append
59  };
60 
61 public:
62  LogFile();
63 
64  void PrintMessage(const Shared::DebugMessage &msg) override;
65 
66  // Open file using given file path, optionally appending if one exists
67  //
68  // TODO: filepath parameter here may be actually used as a pattern
69  // or prefix, while the actual filename could be made by combining
70  // this prefix with current date, game name, and similar additional
71  // useful information. Whether this is to be determined here or on
72  // high-level side remains a question.
73  //
74  bool OpenFile(const String &file_path, OpenMode open_mode = kLogFile_Overwrite);
75  // Close file
76  void CloseFile();
77 
78 private:
80  String _filePath;
81  OpenMode _openMode;
82 };
83 
84 } // namespace Engine
85 } // namespace AGS
86 } // namespace AGS3
87 
88 #endif
Definition: achievements_tables.h:27
Definition: ptr.h:572
Definition: log_file.h:53
Definition: output_handler.h:39
Definition: string.h:62
Definition: output_handler.h:55
Definition: engine.h:144
Definition: ags.h:40