<commit_before>/*
 * Created by <NAME> on 14/04/14.
 * Copyright (c) 2014 Trifork A/S.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


#import <Foundation/Foundation.h>
#import "asl.h"

typedef void (^TFLoggerHandler)(int level, NSString *location,  NSString *msg);

void TFLoggerAddHandler(TFLoggerHandler handler);
void TFLoggerRemoveAllHandlers();

#pragma mark - Predefined log handlers
/**
 *  Standard Error output handler, forwards logs to standard error file descriptor (STDERR_FILENO).
 *  This handler is added to the TFLog streamline by default, so TFLogs are displayed by Xcode debugger.
 *  If you don't want your logs to be send to stderr use @see TFLoggerRemoveAllHandlers() in your appDelegate.
 */
TFLoggerHandler TFStdErrLogHandler();

/**
 *  Apple System Log Facility handler, forwards logs to asl. These are the ones saved on device and displayed by Console.app
 *  This handler is not added to the TFLog streamline by default. In order to have your logs saved on device do the following in your appDelegate:
 *  TFLoggerAddHandler(TFASLLogHandler());
 */
TFLoggerHandler TFASLLogHandler();

// One can define TF_COMPILE_TIME_LOG_LEVEL to set compile time log levels
// all the log operations with levels that are below this setting will be converted to NOOP
// if not defined ASL_LEVEL_DEBUG is set on DEBUG and ASL_LEVEL_ERR on RELEASE.
#ifndef TF_COMPILE_TIME_LOG_LEVEL
    #if DEBUG
        #define TF_COMPILE_TIME_LOG_LEVEL ASL_LEVEL_DEBUG
    #else<commit_msg>Few comments more regarding ASL handler.<commit_after>/*
 * Created by <NAME> on 14/04/14.
 * Copyright (c) 2014 <NAME>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


#import <Foundation/Foundation.h>
#import "asl.h"

typedef void (^TFLoggerHandler)(int level, NSString *location,  NSString *msg);
// TODO: typedef dla handlerow

void TFLoggerAddHandler(TFLoggerHandler handler);
void TFLoggerRemoveAllHandlers();

#pragma mark - Predefined log handlers
/**
 *  Standard Error output handler, forwards logs to standard error file descriptor (STDERR_FILENO).
 *  This handler is added to the TFLog streamline by default, so TFLogs are displayed by Xcode debugger.
 *  If you don't want your logs to be send to stderr use @see TFLoggerRemoveAllHandlers() in your appDelegate.
 */
TFLoggerHandler TFStdErrLogHandler();

/**
 *  Apple System Log Facility handler, forwards logs to asl. These are the ones saved on device and displayed by Console.app
 *  This handler is not added to the TFLog streamline by default. In order to have your logs saved on device do the following in your appDelegate:
 *  TFLoggerAddHandler(TFASLLogHandler());
 *  Default ASL log filter is set to display all messages except those with log levels DEBUG and INFO. That means:
 *  - if you don't use NSLogToTFLoggerAdapter - ALL OF YOUR NSLogs WILL BE SENT TO DEVICE! (baceuse the default NSLog log level is ASL_LEVEL_ERR)
 *  - if you DO use NSLogToTFLoggerAdapter (Recommended) - plain NSLog won't be sent to device log (log level would be DEBUG which is below filter line), except situations where explicitly set the log level using visual format to be ASL_LEVEL_WARNING or higher.
 *  In case you want different ASL filtering policy please use @see asl_set_filter() on your behalf.
 *  ATTENTION: TF_COMPILE_TIME_LOG_LEVEL has precedence over all the other log levels.
 */
TFLoggerHandler TFASLLogHandler();

// One can define TF_COMPILE_TIME_LOG_LEVEL to set compile time log levels
// all the log operations with levels that are below this setting will be converted to NOOP
// if not defined ASL_LEVEL_DEBUG is set on DEBUG and ASL_LEVEL_ERR on RELEASE.
#ifndef TF_COMPILE_TIME_LOG_LEVEL
    #if DEBUG
        #define TF_COMPILE_TIME_LOG_LEVEL ASL_LEVEL_DEBUG
    #else
{'fraction_non_alphanumeric': 0.05737422467263956, 'fraction_numerical': 0.0034458993797381117, 'mean_word_length': 4.415111940298507, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '732182', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1538, 'n_words': 790}