// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { LogLevel } from '../index';
import { InvocationContext } from '../InvocationContext';
import { HookContext, HookContextInit } from './HookContext';

/**
 * Handler for log hooks.
 */
export type LogHookHandler = (context: LogHookContext) => void;

/**
 * Context on a log
 */
export declare class LogHookContext extends HookContext {
    /**
     * For testing purposes only. This will always be constructed for you when run in the context of the Azure Functions runtime
     */
    constructor(init?: LogHookContextInit);

    /**
     * If the log occurs during a function execution, the context object passed to the function handler.
     * Otherwise, undefined.
     */
    readonly invocationContext: InvocationContext | undefined;

    /**
     * 'system' if the log is generated by Azure Functions, 'user' if the log is generated by your own app.
     */
    readonly category: LogCategory;

    /**
     * Changes to this value _will_ affect the resulting log, but only for user-generated logs.
     */
    level: LogLevel;

    /**
     * Changes to this value _will_ affect the resulting log, but only for user-generated logs.
     */
    message: string;
}

/**
 * Object passed to LogHookContext constructors.
 * For testing purposes only
 */
export interface LogHookContextInit extends HookContextInit {
    invocationContext?: InvocationContext;

    level?: LogLevel;

    category?: LogCategory;

    message?: string;
}

export type LogCategory = 'user' | 'system' | 'customMetric';
