1.0.2 • Published 3 years ago

firebase-functions-logging v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Firebase Functions Logging

Firebase Functions Logging plugin that is customizable and uploads your log files in Firebase Storage, so they don't get deleted everytime a function is spinning down.

Installation

npm i firebase-functions-logging

Usage

import { LoggingOptions, setLoggingOptions } from 'firebase-functions-logging';

const storageBucket: Bucket = admin.storage().bucket('gs://your-storage-bucket.appspot.com');

const loggingOptions: LoggingOptions = {
    bucket: app.storage().bucket(storageBucket),
    localPath: '/tmp',
    bucketPath: 'logs',
    timeFormat: {
        locales: 'en-GB',
        timeZone: 'UTC',
        hour12: false
    },
    namingDate: 'day',
    fileName: 'logging',
    fileExtension: '.log',
    uploadTimeout: 60000,
    skipUpload: false
};

setLoggingOptions(loggingOptions);

LoggingOptions

  • bucket - A reference to a Bucket associated with a Storage instance.
  • localPath - Optional: Path where the local .log file will be stored. Default: '/tmp'.
  • bucketPath - Optional: The full path of the folder in your Firebase storage (folders will be created). Default: 'logs'.
  • timeFormat - Optional: Formatting of DateTimes in the logs.
  • namingDate - Optional: The date naming of the log file, and how often a new is to be created. 'day' | 'week' | 'month' | 'year'. Default: 'day'.
  • fileName - Optional: The naming of the log file. Default: 'logging'.
  • fileExtension - Optional: The extension of the log file. Default: '.log'.
  • uploadTimeout - Optional: How often should the file be upload to the bucket in ms Minimum 10000 (10 seconds). Default: 60000 (every minut).
  • skipUpload - Optional: Skip upload of log file to a Firebase Storage Bucket? Mostly used in the development phase. Default: false.

TimeFormat

  • locales - Optional: Locale string or array of locale strings that contain one or more language or locale tags. Example: 'en-GB' or 'en-US'.
  • timeZone - Optional: Timezone for the DateTime in the logs. Example: 'Europe/London' or 'America/New_York'.
  • hour12 - Optional: Optional: Hour12 for the DateTime in the logs. 12 hour (AM/PM) or 24 hour. Default: false.
import { createLogging, Logging } from 'firebase-functions-logging';

const logging: Logging = createLogging(Logging, 'LogID');

Functions

FunctionsDescription
createLogging(logging: Logging, logID:string)Creates a Logging instance with a LogID.
Common Logging Functions
debug(message:any, ...args:any[])Log a DEBUG.
error(message:any, ...args:any[])Log an ERROR.
info(message:any, ...args:any[])Log an INFO.
log(message:any, ...args:any[])Log a LOG.
trace(message:any, ...args:any[])Log a TRACE.
warm(message:any, ...args:any[])Log a WARN.

Enjoy!

/ Team IOspect ;)

https://iospect.dk/

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago