3ds Max USD API Reference
Loading...
Searching...
No Matches
Logging.h
1//**************************************************************************/
2// Copyright (c) 1998-2019 Autodesk, Inc.
3// All rights reserved.
4//
5// Use of this software is subject to the terms of the Autodesk license
6// agreement provided at the time of installation or download, or which
7// otherwise accompanies this software in either electronic or hard copy form.
8//**************************************************************************/
9// DESCRIPTION: Logging utility.
10// AUTHOR: Autodesk Inc.
11//***************************************************************************/
12#pragma once
13
14#include "spdlog/spdlog.h"
15#include "spdlog/common.h"
16#include "spdlog/sinks/basic_file_sink.h"
17
18// MAXX-63363: VS2019 v142: <experimental/filesystem> is deprecated and superseded by the C++17 <filesystem> header
19#if _MSVC_LANG > 201402L
20#include <filesystem>
21namespace fs = std::filesystem;
22#else
23#include <experimental/filesystem>
24namespace fs = std::experimental::filesystem;
25#endif
26
27#include "MaxUsd/MaxUSDAPI.h"
28#include "MaxUsd.h"
29
30#pragma warning(push)
31#pragma warning(disable : 4251) // class 'boost::shared_ptr<T>' needs to have dll-interface to be used by clients of class maxUsd::Log
32
33namespace MAXUSD_NS_DEF {
34
36class MaxUSDAPI Log {
37
39 static std::shared_ptr<spdlog::logger> spdLogger;
40
42 static const size_t maxLogSize = 1048576 * 200;
44 static const size_t maxLogFiles = 5;
45
46 static bool paused;
47
48public:
49
54 enum class Level
55 {
56 Off = 0,
57 Error = 1,
58 Warn = 2,
59 Info = 3
60 };
61
62 struct Options
63 {
64 fs::path path;
65 Level level = Level::Off;
66 };
67
70 class Session
71 {
72 public:
73 Session(const std::string& name, const Options& options);
74 ~Session();
75 };
76
77 static void Message(Level messageType, const std::wstring& message);
78
79 static void Pause();
80 static void Resume();
81
82 template<typename FormatString, typename... Args>
83 static void Warn(const FormatString &fmt, const Args &... args)
84 {
85 if (spdLogger && !paused) {
86 spdLogger->warn(fmt, args...);
87 }
88 }
89
90 template<typename FormatString, typename... Args>
91 static void Info(const FormatString &fmt, const Args &... args)
92 {
93 if (spdLogger && !paused) {
94 spdLogger->info(fmt, args...);
95 }
96 }
97
98 template<typename FormatString, typename... Args>
99 static void Error(const FormatString &fmt, const Args &... args)
100 {
101 if (spdLogger && !paused) {
102 spdLogger->error(fmt, args...);
103 }
104 }
105};
106
107}
108
109#pragma warning(pop)
Definition: Logging.h:71
Simple wrapper for some basic logging functionality provided by the spdlog library.
Definition: Logging.h:36
Level
logging severity level for filtering \comment value of enum is important as it reflects the index in ...
Definition: Logging.h:55
Definition: Logging.h:63