Data Structures | Namespaces | Defines

Logger.h File Reference

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. More...

#include <string>
#include <atscppapi/noncopyable.h>
Include dependency graph for Logger.h:

Go to the source code of this file.

Data Structures

class  atscppapi::Logger
 Create log files that are automatically rolled and cleaned up as space is required. More...

Namespaces

namespace  atscppapi

Defines

#define ATSCPPAPI_PRINTFLIKE(fmt, arg)
#define LOG_DEBUG(log, fmt,...)
 A helper macro for Logger objects that allows you to easily add a debug level message which will include file, line, and function name with the message.
#define LOG_INFO(log, fmt,...)
 A helper macro for Logger objects that allows you to easily add a info level message which will include file, line, and function name with the message.
#define LOG_ERROR(log, fmt,...)
 A helper macro for Logger objects that allows you to easily add a error level message which will include file, line, and function name with the message.
#define STRINGIFY0(x)   #x
#define STRINGIFY(x)   STRINGIFY0(x)
#define LINE_NO   STRINGIFY(__LINE__)
#define TS_DEBUG(tag, fmt,...)
 A helper macro to get access to the Diag messages available in traffic server.
#define TS_ERROR(tag, fmt,...)
 A helper macro to get access to the error.log messages available in traffic server.

Detailed Description

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.

See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Helpers and Classes related to Logging

Warning:
Log rolling doesn't work correctly in 3.2.x see: https://issues.apache.org/jira/browse/TS-1813 Apply the patch in TS-1813 to correct log rolling in 3.2.x

Definition in file Logger.h.


Define Documentation

#define ATSCPPAPI_PRINTFLIKE (   fmt,
  arg 
)

Definition at line 47 of file Logger.h.

#define LINE_NO   STRINGIFY(__LINE__)

Definition at line 105 of file Logger.h.

#define LOG_DEBUG (   log,
  fmt,
  ... 
)
Value:
do { \
    (log).logDebug("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
  } while (false)

A helper macro for Logger objects that allows you to easily add a debug level message which will include file, line, and function name with the message.

It's very easy to use:

  // Suppose you have already created a Logger named logger:
  LOG_DEBUG(logger, "This is a test DEBUG message: %s", "hello");
  // Outputs [file.cc:125, function()] [DEBUG] This is a test DEBUG message: hello.

Definition at line 60 of file Logger.h.

#define LOG_ERROR (   log,
  fmt,
  ... 
)
Value:
do { \
    (log).logError("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
  } while (false)

A helper macro for Logger objects that allows you to easily add a error level message which will include file, line, and function name with the message.

See example in LOG_DEBUG

Definition at line 78 of file Logger.h.

#define LOG_INFO (   log,
  fmt,
  ... 
)
Value:
do { \
    (log).logInfo("[%s:%d, %s()] " fmt, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
  } while (false)

A helper macro for Logger objects that allows you to easily add a info level message which will include file, line, and function name with the message.

See example in LOG_DEBUG

Definition at line 69 of file Logger.h.

#define STRINGIFY (   x  )     STRINGIFY0(x)

Definition at line 104 of file Logger.h.

#define STRINGIFY0 (   x  )     #x

Definition at line 103 of file Logger.h.

#define TS_DEBUG (   tag,
  fmt,
  ... 
)
Value:
do { \
    TSDebug(tag "." __FILE__ ":" LINE_NO , "[%s()] " fmt, __FUNCTION__, ## __VA_ARGS__); \
  } while (false)

A helper macro to get access to the Diag messages available in traffic server.

These can be enabled via traffic_server -T "tag.*" or since this macro includes the file can you further refine to an individual file or even a particular line! This can also be enabled via records.config.

Definition at line 112 of file Logger.h.

#define TS_ERROR (   tag,
  fmt,
  ... 
)
Value:
do { \
    TS_DEBUG(tag, "[ERROR] " fmt, ## __VA_ARGS__); \
    TSError("[%s] [%s:%d, %s()] " fmt, tag, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \
  } while (false)

A helper macro to get access to the error.log messages available in traffic server.

This will also output a DEBUG message visible via traffic_server -T "tag.*", or by enabling the tag in records.config.

Definition at line 122 of file Logger.h.

Referenced by SDK_API_TSConstant(), SDK_API_TSHttpHdr(), SDK_API_TSMimeHdrField(), SDK_API_TSMimeHdrParse(), SDK_API_TSPortDescriptor(), SDK_API_TSUrl(), SDK_API_TSUrlParse(), sdk_sanity_check_mbuffer(), TSHandleMLocRelease(), TSHttpTxnCachedRespTimeGet(), TSHttpTxnCacheLookupUrlGet(), TSHttpTxnConfigFind(), TSHttpTxnNewCacheLookupDo(), TSHttpTxnRedirectRequest(), TSHttpTxnSecondUrlTryLock(), TSHttpTxnServerRespIgnore(), TSHttpTxnUpdateCachedObject(), TSICPCachedReqGet(), TSICPCachedRespGet(), TSMimeHdrFieldValueDateInsert(), and TSMutexLockTry().