Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2018 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import "GoogleDataTransport/GDTCORLibrary/Public/GoogleDataTransport/GDTCORConsoleLogger.h"
18
 
19
volatile NSInteger GDTCORConsoleLoggerLoggingLevel = GDTCORLoggingLevelErrors;
20
 
21
/** The console logger prefix. */
22
static NSString *kGDTCORConsoleLogger = @"[GoogleDataTransport]";
23
 
24
NSString *GDTCORMessageCodeEnumToString(GDTCORMessageCode code) {
25
  return [[NSString alloc] initWithFormat:@"I-GDTCOR%06ld", (long)code];
26
}
27
 
28
void GDTCORLog(GDTCORMessageCode code, GDTCORLoggingLevel logLevel, NSString *format, ...) {
29
// Don't log anything in not debug builds.
30
#if !NDEBUG
31
  if (logLevel >= GDTCORConsoleLoggerLoggingLevel) {
32
    NSString *logFormat = [NSString stringWithFormat:@"%@[%@] %@", kGDTCORConsoleLogger,
33
                                                     GDTCORMessageCodeEnumToString(code), format];
34
    va_list args;
35
    va_start(args, format);
36
    NSLogv(logFormat, args);
37
    va_end(args);
38
  }
39
#endif  // !NDEBUG
40
}
41
 
42
void GDTCORLogAssert(
43
    BOOL wasFatal, NSString *_Nonnull file, NSInteger line, NSString *_Nullable format, ...) {
44
// Don't log anything in not debug builds.
45
#if !NDEBUG
46
  GDTCORMessageCode code = wasFatal ? GDTCORMCEFatalAssertion : GDTCORMCEGeneralError;
47
  NSString *logFormat =
48
      [NSString stringWithFormat:@"%@[%@] (%@:%ld) : %@", kGDTCORConsoleLogger,
49
                                 GDTCORMessageCodeEnumToString(code), file, (long)line, format];
50
  va_list args;
51
  va_start(args, format);
52
  NSLogv(logFormat, args);
53
  va_end(args);
54
#endif  // !NDEBUG
55
}