This file is indexed.

/usr/include/ableton/util/Log.hpp is in ableton-link-dev 1.0.0+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Copyright: 2014, Ableton AG, Berlin, all rights reserved

#pragma once

#include <ableton/util/Injected.hpp>
#include <iostream>
#include <string>

namespace ableton
{
namespace util
{

// Null object for the Log concept
struct NullLog
{
  template <typename T>
  friend const NullLog& operator<<(const NullLog& log, const T&)
  {
    return log;
  }

  friend const NullLog& debug(const NullLog& log)
  {
    return log;
  }

  friend const NullLog& info(const NullLog& log)
  {
    return log;
  }

  friend const NullLog& warning(const NullLog& log)
  {
    return log;
  }

  friend const NullLog& error(const NullLog& log)
  {
    return log;
  }

  friend NullLog channel(const NullLog&, std::string)
  {
    return {};
  }
};

// std streams-based log
struct StdLog
{
  StdLog(std::string channelName = "")
    : mChannelName(std::move(channelName))
  {
  }

  // Stream type used by std log to prepend the channel name to log messages
  struct StdLogStream
  {
    StdLogStream(std::ostream& ioStream, const std::string& channelName)
      : mpIoStream(&ioStream)
      , mChannelName(channelName)
    {
      ioStream << "[" << mChannelName << "] ";
    }

    StdLogStream(StdLogStream&& rhs)
      : mpIoStream(rhs.mpIoStream)
      , mChannelName(rhs.mChannelName)
    {
      rhs.mpIoStream = nullptr;
    }

    ~StdLogStream()
    {
      if (mpIoStream)
      {
        (*mpIoStream) << "\n";
      }
    }

    template <typename T>
    std::ostream& operator<<(const T& rhs)
    {
      (*mpIoStream) << rhs;
      return *mpIoStream;
    }

    std::ostream* mpIoStream;
    const std::string& mChannelName;
  };

  friend StdLogStream debug(const StdLog& log)
  {
    return {std::clog, log.mChannelName};
  }

  friend StdLogStream info(const StdLog& log)
  {
    return {std::clog, log.mChannelName};
  }

  friend StdLogStream warning(const StdLog& log)
  {
    return {std::clog, log.mChannelName};
  }

  friend StdLogStream error(const StdLog& log)
  {
    return {std::cerr, log.mChannelName};
  }

  friend StdLog channel(const StdLog& log, const std::string& channelName)
  {
    auto compositeName =
      log.mChannelName.empty() ? channelName : log.mChannelName + "::" + channelName;
    return {std::move(compositeName)};
  }

  std::string mChannelName;
};

// Log adapter that adds timestamps
template <typename Log>
struct Timestamped
{
  using InnerLog = typename util::Injected<Log>::type;

  Timestamped() = default;

  Timestamped(util::Injected<Log> log)
    : mLog(std::move(log))
  {
  }

  util::Injected<Log> mLog;

  friend decltype(debug(std::declval<InnerLog>())) debug(const Timestamped& log)
  {
    return log.logTimestamp(debug(*log.mLog));
  }

  friend decltype(info(std::declval<InnerLog>())) info(const Timestamped& log)
  {
    return log.logTimestamp(info(*log.mLog));
  }

  friend decltype(warning(std::declval<InnerLog>())) warning(const Timestamped& log)
  {
    return log.logTimestamp(warning(*log.mLog));
  }

  friend decltype(error(std::declval<InnerLog>())) error(const Timestamped& log)
  {
    return log.logTimestamp(error(*log.mLog));
  }

  friend Timestamped channel(const Timestamped& log, const std::string& channelName)
  {
    return {channel(*log.mLog, channelName)};
  }

  template <typename Stream>
  Stream logTimestamp(Stream&& streamRef) const
  {
    using namespace std::chrono;
    Stream stream = std::forward<Stream>(streamRef);
    stream << "|"
           << duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()
           << "ms| ";
    return stream;
  }
};

} // namespace util
} // namespace ableton