storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/mint/build/aws-sdk-java/src/MintLogger.java (about)

     1  /*
     2   * Minio Java SDK for Amazon S3 Compatible Cloud Storage,
     3   * (C) 2015, 2016, 2017, 2018 Minio, Inc.
     4   *
     5   * Licensed under the Apache License, Version 2.0 (the "License");
     6   * you may not use this file except in compliance with the License.
     7   * You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package io.minio.awssdk.tests;
    19  
    20  import com.fasterxml.jackson.annotation.JsonAutoDetect;
    21  import com.fasterxml.jackson.annotation.JsonIgnore;
    22  import com.fasterxml.jackson.annotation.JsonInclude.Include;
    23  import com.fasterxml.jackson.annotation.JsonProperty;
    24  import com.fasterxml.jackson.core.JsonProcessingException;
    25  import com.fasterxml.jackson.databind.ObjectMapper;
    26  
    27  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
    28  public class MintLogger {
    29  
    30      @JsonProperty("name")
    31      private String name;
    32  
    33      @JsonProperty("function")
    34      private String function;
    35  
    36      @JsonProperty("args")
    37      private String args;
    38  
    39      @JsonProperty("duration")
    40      private long duration;
    41  
    42      @JsonProperty("status")
    43      private String status;
    44  
    45      @JsonProperty("alert")
    46      private String alert;
    47  
    48      @JsonProperty("message")
    49      private String message;
    50  
    51      @JsonProperty("error")
    52      private String error;
    53  
    54      /**
    55       * Constructor.
    56       **/
    57      public MintLogger(String function,
    58              String args,
    59              long duration,
    60              String status,
    61              String alert,
    62              String message,
    63              String error) {
    64          this.name = "aws-sdk-java";
    65          this.function = function;
    66          this.duration = duration;
    67          this.args = args;
    68          this.status = status;
    69          this.alert = alert;
    70          this.message = message;
    71          this.error = error;
    72      }
    73  
    74      /**
    75       * Return JSON Log Entry.
    76       **/
    77      @JsonIgnore
    78      public String toString() {
    79  
    80          try {
    81              return new ObjectMapper().setSerializationInclusion(Include.NON_NULL).writeValueAsString(this);
    82          } catch (JsonProcessingException e) {
    83              e.printStackTrace();
    84          }
    85          return "";
    86      }
    87  
    88      /**
    89       * Return Alert.
    90       **/
    91      @JsonIgnore
    92      public String alert() {
    93          return alert;
    94      }
    95  
    96      /**
    97       * Return Error.
    98       **/
    99      @JsonIgnore
   100      public String error() {
   101          return error;
   102      }
   103  
   104      /**
   105       * Return Message.
   106       **/
   107      @JsonIgnore
   108      public String message() {
   109          return message;
   110      }
   111  
   112      /**
   113       * Return args.
   114       **/
   115      @JsonIgnore
   116      public String args() {
   117          return args;
   118      }
   119  
   120      /**
   121       * Return status.
   122       **/
   123      @JsonIgnore
   124      public String status() {
   125          return status;
   126      }
   127  
   128      /**
   129       * Return name.
   130       **/
   131      @JsonIgnore
   132      public String name() {
   133          return name;
   134      }
   135  
   136      /**
   137       * Return function.
   138       **/
   139      @JsonIgnore
   140      public String function() {
   141          return function;
   142      }
   143  
   144      /**
   145       * Return duration.
   146       **/
   147      @JsonIgnore
   148      public long duration() {
   149          return duration;
   150      }
   151  }