Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
//===- Logging.h - MLIR LSP Server Logging ----------------------*- C++ -*-===//
//===- Logging.h - LSP Server Logging ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
#define MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
#ifndef LLVM_SUPPORT_LSP_LOGGING_H
#define LLVM_SUPPORT_LSP_LOGGING_H

#include "mlir/Support/LLVM.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
#include <memory>
#include <mutex>

namespace mlir {
namespace llvm {
namespace lsp {

/// This class represents the main interface for logging, and allows for
Expand All @@ -26,21 +25,18 @@ class Logger {
enum class Level { Debug, Info, Error };

/// Set the severity level of the logger.
static void setLogLevel(Level logLevel);
static void setLogLevel(Level LogLevel);

/// Initiate a log message at various severity levels. These should be called
/// after a call to `initialize`.
template <typename... Ts>
static void debug(const char *fmt, Ts &&...vals) {
log(Level::Debug, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
template <typename... Ts> static void debug(const char *Fmt, Ts &&...Vals) {
log(Level::Debug, Fmt, llvm::formatv(Fmt, std::forward<Ts>(Vals)...));
}
template <typename... Ts>
static void info(const char *fmt, Ts &&...vals) {
log(Level::Info, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
template <typename... Ts> static void info(const char *Fmt, Ts &&...Vals) {
log(Level::Info, Fmt, llvm::formatv(Fmt, std::forward<Ts>(Vals)...));
}
template <typename... Ts>
static void error(const char *fmt, Ts &&...vals) {
log(Level::Error, fmt, llvm::formatv(fmt, std::forward<Ts>(vals)...));
template <typename... Ts> static void error(const char *Fmt, Ts &&...Vals) {
log(Level::Error, Fmt, llvm::formatv(Fmt, std::forward<Ts>(Vals)...));
}

private:
Expand All @@ -50,16 +46,16 @@ class Logger {
static Logger &get();

/// Start a log message with the given severity level.
static void log(Level logLevel, const char *fmt,
const llvm::formatv_object_base &message);
static void log(Level LogLevel, const char *Fmt,
const llvm::formatv_object_base &Message);

/// The minimum logging level. Messages with lower level are ignored.
Level logLevel = Level::Error;
Level LogLevel = Level::Error;

/// A mutex used to guard logging.
std::mutex mutex;
std::mutex Mutex;
};
} // namespace lsp
} // namespace mlir
} // namespace llvm

#endif // MLIR_TOOLS_LSPSERVERSUPPORT_LOGGING_H
#endif // LLVM_SUPPORT_LSP_LOGGING_H
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H
#define MLIR_TOOLS_LSPSERVERSUPPORT_PROTOCOL_H
#ifndef LLVM_SUPPORT_LSP_PROTOCOL_H
#define LLVM_SUPPORT_LSP_PROTOCOL_H

#include "mlir/Support/LLVM.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/LogicalResult.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <bitset>
#include <optional>
#include <string>
#include <utility>
#include <vector>

namespace mlir {
// This file is using the LSP syntax for identifier names which is different
// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
// disabling one check here.
// NOLINTBEGIN(readability-identifier-naming)

namespace llvm {
namespace lsp {

enum class ErrorCode {
Expand Down Expand Up @@ -1241,12 +1245,11 @@ struct CodeAction {
llvm::json::Value toJSON(const CodeAction &);

} // namespace lsp
} // namespace mlir
} // namespace llvm

namespace llvm {
template <>
struct format_provider<mlir::lsp::Position> {
static void format(const mlir::lsp::Position &pos, raw_ostream &os,
template <> struct format_provider<llvm::lsp::Position> {
static void format(const llvm::lsp::Position &pos, raw_ostream &os,
StringRef style) {
assert(style.empty() && "style modifiers for this type are not supported");
os << pos;
Expand All @@ -1255,3 +1258,5 @@ struct format_provider<mlir::lsp::Position> {
} // namespace llvm

#endif

// NOLINTEND(readability-identifier-naming)
Loading