ó ôBQc@s@ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z dd l mZdd l mZddl mZddl mZddl mZddl mZddlmZdZdefd„ƒYZdS(i˙˙˙˙(tCommand(t COMMAND_NAME(tCOMMAND_NAME_ALIASES(tCONFIG_REQUIRED(t FILE_URIS_OK(tMAX_ARGS(tMIN_ARGS(tPROVIDER_URIS_OK(tSUPPORTED_SUB_ARGS(tURIS_START_ARG(tCommandException(t HELP_NAME(tHELP_NAME_ALIASES(tHELP_ONE_LINE_SUMMARY(t HELP_TEXT(tHelpType(t HELP_TYPE(tNO_MAXs| SYNOPSIS gsutil enablelogging -b logging_bucket [-o log_object_prefix] uri... DESCRIPTION Google Cloud Storage offers access logs and storage data in the form of CSV files that you can download and view. Access logs provide information for all of the requests made on a specified bucket in the last 24 hours, while the storage logs provide information about the storage consumption of that bucket for the last 24 hour period. The logs and storage data files are automatically created as new objects in a bucket that you specify, in 24 hour intervals. The gsutil enablelogging command will enable access logging of the buckets named by the specified uris, outputting log files in the specified logging_bucket. logging_bucket must already exist, and all URIs must name buckets (e.g., gs://bucket). For example, the command: gsutil enablelogging -b gs://my_logging_bucket -o AccessLog \ gs://my_bucket1 gs://my_bucket2 will cause all read and write activity to objects in gs://mybucket1 and gs://mybucket2 to be logged to objects prefixed with the name "AccessLog", with those log objects written to the bucket gs://my_logging_bucket. Note that log data may contain sensitive information, so you should make sure to set an appropriate default bucket ACL to protect that data. (See "gsutil help setdefacl".) You can check logging status using the gsutil getlogging command. For log format details see "gsutil help getlogging". OPTIONS -b bucket Specifies the log bucket. -o prefix Specifies the prefix for log object names. Default value is the bucket name. tEnableLoggingCommandcBs‘eZdZi de6ge6de6ee6de6e e 6e e 6de 6e e6Zide6dddge6eje6de6ee6Zd „ZRS( s/Implementation of gsutil enablelogging command.t enableloggingisb:o:itloggingtlogstlogsEnable logging on bucketsc Cse|j|jƒ}|s'tdƒ‚nd}d}xM|jD]B\}}|dkrj|jj|ƒ}n|dkr=|}q=q=W|s˜tdƒ‚n|jƒsłtdƒ‚nt}x|jD]…}x||j |ƒj ƒD]e}|j ƒrtdƒ‚nt }d|GH|j jd||jƒ|j|j|t|jƒqßWqĂW|satd ƒ‚nd S( Ns5enablelogging command spanning providers not allowed.s-bs-os/enablelogging requires '-b ' options#-b option must specify a bucket uris*enablelogging cannot be applied to objectssEnabling logging on %s...RsNo URIs matchedi(tUrisAreForSingleProvidertargsR tNonetsub_optst suri_buildert StorageUrit names_buckettFalsetWildcardIteratortIterUrist names_objecttTruetproj_id_handlertFillInProjectHeaderIfNeededtheaderstenable_loggingt bucket_name( tselft storage_urittarget_bucket_urit target_prefixtopttopt_argt did_some_workturi_strturi((s:/tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/enablelogging.pyt RunCommandrs8       (t__name__t __module__t__doc__RRRRRRRRRR R"Rt command_specR R Rt COMMAND_HELPRR t_detailed_help_textRt help_specR1(((s:/tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/enablelogging.pyRLs$   N(t gslib.commandRRRRRRRRRR tgslib.exceptionR tgslib.help_providerR R R RRRt gslib.utilRR7R(((s:/tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/enablelogging.pyts&)