1 | |
2 | // |
3 | // This source file is part of appleseed. |
4 | // Visit http://appleseedhq.net/ for additional information and resources. |
5 | // |
6 | // This software is released under the MIT license. |
7 | // |
8 | // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited |
9 | // Copyright (c) 2014-2017 Francois Beaune, The appleseedhq Organization |
10 | // |
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
12 | // of this software and associated documentation files (the "Software"), to deal |
13 | // in the Software without restriction, including without limitation the rights |
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
15 | // copies of the Software, and to permit persons to whom the Software is |
16 | // furnished to do so, subject to the following conditions: |
17 | // |
18 | // The above copyright notice and this permission notice shall be included in |
19 | // all copies or substantial portions of the Software. |
20 | // |
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
27 | // THE SOFTWARE. |
28 | // |
29 | |
30 | #ifndef APPLESEED_FOUNDATION_UTILITY_LOG_HELPERS_H |
31 | #define APPLESEED_FOUNDATION_UTILITY_LOG_HELPERS_H |
32 | |
33 | // appleseed.foundation headers. |
34 | #include "foundation/utility/log/logger.h" |
35 | #include "foundation/utility/log/logmessage.h" |
36 | |
37 | namespace foundation |
38 | { |
39 | |
40 | // |
41 | // Write a message to a logger. |
42 | // |
43 | |
44 | #define LOG(logger, category, ...) \ |
45 | do { \ |
46 | (logger).write( \ |
47 | category, \ |
48 | __FILE__, \ |
49 | __LINE__, \ |
50 | __VA_ARGS__); \ |
51 | } while (0) |
52 | |
53 | |
54 | // |
55 | // Write an info message to a logger. |
56 | // |
57 | |
58 | #define LOG_INFO(logger, ...) \ |
59 | do { \ |
60 | (logger).write( \ |
61 | foundation::LogMessage::Info, \ |
62 | __FILE__, \ |
63 | __LINE__, \ |
64 | __VA_ARGS__); \ |
65 | } while (0) |
66 | |
67 | |
68 | // |
69 | // Write a debug message to a logger. |
70 | // |
71 | |
72 | #define LOG_DEBUG(logger, ...) \ |
73 | do { \ |
74 | (logger).write( \ |
75 | foundation::LogMessage::Debug, \ |
76 | __FILE__, \ |
77 | __LINE__, \ |
78 | __VA_ARGS__); \ |
79 | } while (0) |
80 | |
81 | |
82 | // |
83 | // Write a warning message to a logger. |
84 | // |
85 | |
86 | #define LOG_WARNING(logger, ...) \ |
87 | do { \ |
88 | (logger).write( \ |
89 | foundation::LogMessage::Warning, \ |
90 | __FILE__, \ |
91 | __LINE__, \ |
92 | __VA_ARGS__); \ |
93 | } while (0) |
94 | |
95 | |
96 | // |
97 | // Write an error message to a logger. |
98 | // |
99 | |
100 | #define LOG_ERROR(logger, ...) \ |
101 | do { \ |
102 | (logger).write( \ |
103 | foundation::LogMessage::Error, \ |
104 | __FILE__, \ |
105 | __LINE__, \ |
106 | __VA_ARGS__); \ |
107 | } while (0) |
108 | |
109 | |
110 | // |
111 | // Write a fatal error message to a logger. |
112 | // |
113 | |
114 | #define LOG_FATAL(logger, ...) \ |
115 | do { \ |
116 | (logger).write( \ |
117 | foundation::LogMessage::Fatal, \ |
118 | __FILE__, \ |
119 | __LINE__, \ |
120 | __VA_ARGS__); \ |
121 | } while (0) |
122 | |
123 | } // namespace foundation |
124 | |
125 | #endif // !APPLESEED_FOUNDATION_UTILITY_LOG_HELPERS_H |
126 | |