mz_pgwire_common/
severity.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10#[derive(Clone, Copy, Debug, Eq, PartialEq)]
11pub enum Severity {
12    Panic,
13    Fatal,
14    Error,
15    Warning,
16    Notice,
17    Debug,
18    Info,
19    Log,
20}
21
22impl Severity {
23    pub fn is_error(&self) -> bool {
24        matches!(self, Severity::Panic | Severity::Fatal | Severity::Error)
25    }
26
27    pub fn is_fatal(&self) -> bool {
28        matches!(self, Severity::Fatal)
29    }
30
31    pub fn as_str(&self) -> &'static str {
32        match self {
33            Severity::Error => "ERROR",
34            Severity::Fatal => "FATAL",
35            Severity::Panic => "PANIC",
36            Severity::Warning => "WARNING",
37            Severity::Notice => "NOTICE",
38            Severity::Debug => "DEBUG",
39            Severity::Info => "INFO",
40            Severity::Log => "LOG",
41        }
42    }
43}